Help making an FPS performance warner

Hello!

I need some help making my FPS performance warner. This is how it looks like in-game:
unknown3

Legend
Orange = Unstable performance, low FPS ---- NAME: performanceWarning
White symbol = opens game status GUI (where FPS is listed) ---- NAME: info

If the FPS is very low, the orange will turn red.

I’ve tried to add this script to performanceWarning which will decide when it will be visible or change color to orange/red. These are the two things I’ve tried to do:

First attempt

Second attempt

I don’t know what else can fix this, any help would be appreciated!

NOTE: try to write your answer here by tommorow because I’m travelling, but it’s totally fine if you can’t manage . :slight_smile:

Forgot to mention, FPS_Number is the text label which correctly displays the current FPS.

Try this:

local RunService = game:GetService("RunService")
local FpsLabel = script.Parent
local TimeFunction = RunService:IsRunning() and time or os.clock

local LastIteration, Start
local FrameUpdateTable = {}

local function HeartbeatUpdate()
	LastIteration = TimeFunction()
	for Index = #FrameUpdateTable, 1, -1 do
		FrameUpdateTable[Index + 1] = FrameUpdateTable[Index] >= LastIteration - 1 and FrameUpdateTable[Index] or nil
	end

	FrameUpdateTable[1] = LastIteration
	local FPS = tostring(math.floor(TimeFunction() - Start >= 1 and #FrameUpdateTable or #FrameUpdateTable / (TimeFunction() - Start)))
	print(FPS)
end

Start = TimeFunction()
RunService.Heartbeat:Connect(HeartbeatUpdate)

Then remove the print statement and add the if statement for something like:

if FPS >  30 then
 blablabla
2 Likes

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.