#FPS Counter Bug
44 messages · Page 1 of 1 (latest)
local RunService = game:GetService("RunService")
local FpsLabel = script.Parent.FPSShow
-- Use a simpler time tracking method
local frameCount = 0
local lastTime = tick()
local updateInterval = 0.5 -- Update every half second
local function updateFPS()
frameCount = frameCount + 1
local currentTime = tick()
local deltaTime = currentTime - lastTime
-- Only update display every updateInterval seconds
if deltaTime >= updateInterval then
local fps = math.floor(frameCount / deltaTime + 0.5) -- Round to nearest integer
FpsLabel.Text = tostring(fps)
frameCount = 0
lastTime = currentTime
end
end
-- Disconnect any existing connection first
if script.Parent:FindFirstChild("HeartbeatConnection") then
script.Parent.HeartbeatConnection:Disconnect()
end
-- Store the connection so we can disconnect it later if needed
local connection = RunService.Heartbeat:Connect(updateFPS)
script.Parent:WaitForChild("HeartbeatConnection", 5) -- Wait up to 5 seconds
script.Parent.HeartbeatConnection = connection
I’m at work rn on break can’t really do much else. But you’re welcome anyway
Heart beat is the server side equivalent to render stepped.
Here’s a client side version. If you’re not skilled scripting don’t be so picky about your responses considering they are free.
local RunService = game:GetService("RunService")
local FpsLabel = script.Parent.FPSShow
local frameTimes = {}
local maxSamples = 30 -- Number of recent frame times to average
local updateInterval = 0.1 -- Update display every 0.1 seconds
local lastUpdate = tick()
local function updateFPS(deltaTime)
-- Add the current frame's delta time
table.insert(frameTimes, deltaTime)
-- Remove old samples
if #frameTimes > maxSamples then
table.remove(frameTimes, 1)
end
-- Only update the display at our specified interval
local currentTime = tick()
if currentTime - lastUpdate >= updateInterval then
-- Calculate average FPS
local totalTime = 0
for _, dt in ipairs(frameTimes) do
totalTime = totalTime + dt
end
local averageDelta = totalTime / #frameTimes
local fps = math.floor(1 / averageDelta + 0.5) -- Round to nearest integer
-- Ensure we show something even at very low FPS
if fps < 1 then fps = 1 end -- Minimum display value
FpsLabel.Text = tostring(fps)
lastUpdate = currentTime
end
end
-- Clean up any existing connection
local existingConnection = script:GetAttribute("RenderConnection")
if existingConnection then
existingConnection:Disconnect()
end
-- Connect and store the connection
local connection = RunService.RenderStepped:Connect(updateFPS)
script:SetAttribute("RenderConnection", connection)
Now if it works you owe AI an apology 🤣
lol
script:SetAttribute("RenderConnection", connection)
fr?
Likely to prevent multiple connections from stacking
connection is not valid for an attribute
And this is why you need to know how to code in the first place before utilizing AI. AI is very useful but if you don’t know what you’re doing then AI won’t be that much help.
Make the adjustments as needed. AI isn’t a crutch, it’ll get you in the ball park but you still have to hit the ball.
It feels irresponsible to not validate AI code before sharing it as if it's a solution
Well, I am at work on break, not sitting in front of my PC on a weekday. I apologize for offering help… for free during my break.
Which you could do by offering solutions and not copying and pasting AI code without validating it
Grey role with over 1B visits but it is what it is.
Why is someone with 1B visits copying and pasting AI code without validating it
New account big boy
Because I’m at work, working for a living, there’s a lot of shit talk for someone offering free help.
** You are now Level 3! **
Look Jaxavali up on twitter/X 😂
I work too! Wild world.
But if I don't have the capacity to help fully in a responsible way, I don't
Why don’t you mind your business
You too buddy 🙂
I am. This conversation didn’t involve you
You’re seeking attention
Well since it's on a public server it can involve me! hehe 🙂
I wanna help people as best I can, so when someone posts AI code without validating it, I want to stop that so it doesn't cause people issues!
I guess I bought the 40k+ followers too 😂
His original code was causing issues, it’s poorly written.
What your username I’ll shout you out rn
The AI code was also poorly written!
Because it tried to correct a terrible code
So then why would you post it? and why insult the dev you're trying to help? Nice guy.
Check my posts
nice it still doesnt change that you're a chatgpt warrior
Well, it is what it is. I’ve made over $80k on Roblox so…
That doesn't change anything though
How many visits you have, or how much money you make, doesnt change that you pasted unvalidated AI code, which can confuse devs and take up space.
Just only help if you have the time to sit down and offer up solutions that you didn't copy and paste without parsing.
Thats all I'm truly saying. Help is appreciated, but you have to be careful with the kind of help you give.
I’ll go. But please learn the basics of code and also, be more appreciative of people who offer help since you’re not paying for it. And if moon is still yapping tell them it’s no use, I blocked them already 😂
bro you're right now being so funny, keep writing
What a lazy dude, damn.
Sorry this thread got this way. I wish I could honestly help you