Hey, so I’ve run into a minor issue with a loop where I move npcs forward on the server in a heartbeat loop, so there is a finish line and i start a timer from the start point and on studio they are visibly faster the when i run it in game and also there times when im in studio are always below 10 seconds, but in game they never go below 10, and I haven’t changd the scripts or anything
The decelerate is just a function from a module that graually reduces the humanoid’s walkspeed
connection = game:GetService("RunService").Heartbeat:Connect(function(dt)
participant.Humanoid:MoveTo(participant.PrimaryPart.Position + participant.PrimaryPart.CFrame.LookVector * participant.Humanoid.WalkSpeed)
Mehcanic:Decelerate(participant.Humanoid, animation, dt)
The HeartBeat function could be slowing it down because it is happening last in the loading sequence so maybe try stepped (Middle loaded) or renderstepped (First loaded).
So what could I do about it or is there nothing I can do?
Also this is the timer if this even helps
local startTime = os.clock()
local prevTime = startTime
while self.timer do
local currentTime = os.clock()
local deltaTime = currentTime - prevTime
self.elapsedTime += deltaTime
if self.elapsedTime > self.maxEventTime then
prevTime = currentTime
Is this a server or local script?
I handle everythign I’ve said on the server nothing locally, what can I do because this is a really annoying problem @Wire_Rack
When running in
Studio, you are running on your Computer, rather than a Roblox Server, however in Game, you are connecting to Roblox’s actual Servers, which depending on your connection, can be delayed (typically applies to Server)
Yeah but I was in a server with just me in that would mean I would get the best ping and all that stuff, so is this just something I have to deal with?
With the Server, it would have to be something that you would need to deal with.
If you create the Server (on actual Roblox Servers), it will be based around your location, but if your connection is still bad, it will still cause latency.
Edit: You can probably have “synchronize” the Client and Server