Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Localscript Depending on Client FPS?

Hello, I am trying to make a part move up and down at the same speed for all players, but this localscript makes it so that it changes speed depending on the fps, slower fps makes it slower and faster fps makes it faster.

local RunService = game:GetService("RunService")
local part = workspace:WaitForChild("LollipopUnion2")
local loopNumber = 200
local length = 50

while true do
	for i = 0, loopNumber, 1 do
		part.Position = part.Position + Vector3.new(0, length / loopNumber, 0)
		RunService.Stepped:Wait()
	end
	for i = 0, loopNumber, 1 do
		part.Position = part.Position - Vector3.new( 0, length / loopNumber, 0)
		RunService.Stepped:Wait()
	end
end

2 answers

✓ Accepted answer

The reason for the change in speed is the frame rate.

RunService.Stepped has a parameter that defines the time since the last time the event was fired.

deltaTime double The time (in seconds) that has elapsed since the previous frame

If the player has a lower frame rate, the part will move slower for them.

If you need more help, contact me on Discord (phxntxsmic#2021)

1 comment

0

Thank you, I sent you a friend request on discord, marco.py

If you're doing it for the whole server, wouldn't you do a ServerScript? And it's probaby because of lag, lower FPS is more lag so it might go slower

1 comment

0

The reason I didn't do it in server is because it is not smooth / laggy.

This discussion is preserved as it was. New answers, comments, and votes are closed.