Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Localscript Depending on Client FPS?

Asked by 3 years ago

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

Log in to vote
3
Answered by
appxritixn 2235 Moderation Voter Community Moderator
3 years ago

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)

0
Thank you, I sent you a friend request on discord, marco.py mariohead13 129 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

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

0
The reason I didn't do it in server is because it is not smooth / laggy. mariohead13 129 — 3y

Answer this question