Why does my script run faster on studio but on normal roblox servers its slow?

i have fireballs that i made this is the script that makes it move

local part = script.Parent

while true do
part.CFrame = part.CFrame + part.CFrame.LookVector
task.wait()
end

1 Like

This is likely because you are running your game at an fps higher than 60 fps, and when doing a local test in studio, the client and the server both run at the target fps you’ve set in the settings (I assume you set it above 60 fps), which is a bit annoying…
Roblox servers in game always run at 60 fps (unless they are lagging)

task.wait(), when it has no argument, runs on every frame, so at 60 fps it will run 60 times per second, and at 120, it’ll run 120 times per second

You should probably take deltatime into a count when updating your part’s position:

local part = script.Parent

while true do
    local dt = task.wait()
    part.CFrame = part.CFrame + part.CFrame.LookVector * dt * 60
end

DeltaTime is the amount of time from the last frame to the current frame. By doing so, the distance is adjusted by the time difference between frames, which will lead to a more consistent movement

4 Likes

i never knew such thing like that

1 Like

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