Idk how to start these off, but basically. The only issue I really care about here is that, at high speeds, other players tend to lag behind on other clients. For example,
we have client A and client B. Client A is at the front of a platform, Client B is aswell.
As the platform moves at 50 studs per second, Client A sees Client B flickering between at the front of the platform, and at the back of the platform. And client B sees the same, but instead of Client B flickering, it’s Client A.
How can I fix this while keeping the script:
- Simple
- In one local script in StarterCharacterScripts.
There is an object value instead of a raycast so that it’s easier to switch people’s platforms.
Here’s my script.
local plrs = game:GetService("Players")
local plr = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local previousPart
local previousMovingPartCFrame
while true do
if humanoid.Health <= 0 then
return
end
local movingPart = script.Parent.MmamiaObjectValue.Value
if movingPart then
if previousMovingPartCFrame and movingPart == previousPart then
local offset = previousMovingPartCFrame:ToObjectSpace(hrp.CFrame)
hrp.CFrame = movingPart.CFrame:ToWorldSpace(offset)
else
local offset = movingPart.CFrame:ToObjectSpace(hrp.CFrame)
hrp.CFrame = movingPart.CFrame:ToWorldSpace(offset)
end
end
previousPart = movingPart
previousMovingPartCFrame = movingPart and movingPart.CFrame
wait(.01)
end
1 Like
Hmmm, I’m pretty sure that’s because of replication – you can try using RunService to make it smoother but at the end of the day, it would naturally have discrepancies. To visualize:
PlayerA tells server their position → server gets the position and sends it to all the other players → let’s say PlayerB gets that position and renders PlayerA on their client
..but of course uh oh, during all of that, PlayerA has most likely moved from what PlayerB received. Especially with how fast your platforms are going.
A cheeky solution to this is to apply the code to other players aswell? This won’t affect them as you’re only doing it for the sole purpose of visuals.
What I mean is something like this:
local PS = game:GetService("Players")
local RNS = game:GetService("RunService")
local player = PS.LocalPlayer
RNS.RenderStepped:Connect(function() -- our sneaky lil client smoothing
for _,v in PS:GetPlayers() do
if v == player then -- dont do the code on ourselves
continue
end
-- teleport that player on where they should be on the platform (for your client)
-- ofc ur gonna have to check if theyre actually on the platform before u run the code and
-- other things that u might need to consider
end
end)
This is honestly just a sort of brainstorm? Could work, could also not – but you can consider trying something like this.
It makes sense, but it didn’t fix the lagging clients. Maybe it’s something related to the client syncing or something? idrk.
Forgot to mention that despite it being client sided, the movement transfers over to the server side, which is showing all players as flickering behind the platform. So maybe it’s a server issue?
This is what occurs when the script typically runs, it’s not very fun.
It’s stopping my ability to improve my train systems.