Created
December 25, 2024 18:43
-
-
Save PatoFlamejanteTV/e127bedd182f8d63276a303d30d31ce3 to your computer and use it in GitHub Desktop.
FramesPerSecond system, by me
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--!strict | |
-- ORIGINAL: https://pastebin.com/JBRampUT | |
-- Modded by UltimateQuack | |
local runService = game:GetService("RunService") | |
local fpsLabel = script.Parent | |
local function GetFPS(delay) | |
local startTime = tick() | |
local frames = 0 | |
local heartbeatConnection = runService.Heartbeat:Connect(function() | |
frames = frames + 1 | |
end) | |
task.wait(delay) | |
heartbeatConnection:Disconnect() | |
local elapsedTime = tick() - startTime | |
local fps = frames / elapsedTime | |
return math.ceil(fps) | |
end | |
while true do | |
local fps = GetFPS(0.1) | |
if fps >= 60 then | |
fpsLabel.TextColor3 = Color3.fromRGB( | |
0, | |
255, | |
0 | |
) | |
elseif fps <= 59 and fps > 50 then | |
fpsLabel.TextColor3 = Color3.fromRGB( | |
255, | |
170, | |
0 | |
) | |
elseif fps <= 49 and fps > 30 then | |
fpsLabel.TextColor3 = Color3.fromRGB( | |
255, | |
85, | |
0 | |
) | |
elseif fps <= 29 then | |
fpsLabel.TextColor3 = Color3.fromRGB( | |
255, | |
0, | |
0 | |
) | |
end | |
fpsLabel.Text = tostring(fps) .. " FPS [" .. "0.1s" .. "]" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment