Also, I used to have problems with this as well with an old gun system I was messing around with, and I was too lazy to scale the increments by delta time, so you can just use a ratio with delta time since your increments are already for 60 FPS.
Scaling the values to find a ratio like 60 : userFPS is an easy way to scale the values, so it should look the same on every frame rate.
Example: 60 : 120 = 0.5, will make it slower to compensate to look the same, because 120 times a second is double 60, because your increments are made for 60 FPS
Also, you should define RunService outside of the loop since it’s a constant.
local rs = game:GetService("RunService")
local fps
local ratio
local number = 0
while true do
fps = 1/(rs.Heartbeat:Wait())
print(fps)
ratio = 60/fps -- Since it needs to be slower at higher framerates, the number needs to smaller as dt decreases
number = number + 1
local position = ((4 * 100) * number) * ratio
end
Heartbeat and other RunService events are variable frequency, so the frequency which they are fired based on a user’s frame rate.
Your increments are for 60 fps, meaning that it needs to be called 60 times a second for it to look good.
120 FPS is double that, 120 times a second, which is why the speed and stuff is faster. It’s twice as fast.
If you capped to 30, you should see that it gets slower, because it’s called 30 times in a second. Which means it would be about half as fast.
Also, your code is pretty vague, so I’m not sure if this is going to work. Can you provide a larger snippet so I can have more context? How are number and position being used?