I’ve searched everywhere but couldn’t find any solution.
I tried to make a loop that forces the character in the Server and the Client to sync but it didn’t work at all. Here’s the code that I tried (i’m new to scripting btw):
The server script:
plrs.PlayerAdded:Connect(function(plr)
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
char:WaitForChild("HumanoidRootPart"):GetPropertyChangedSignal("Position"):Connect(function()
wait(0.1)
game:GetService("ReplicatedStorage"):WaitForChild("SyncCharacter"):FireClient(plr, char.HumanoidRootPart.CFrame)
end)
end
end)
The local script:
game:GetService("ReplicatedStorage"):WaitForChild("SyncCharacter").OnClientEvent:Connect(function(charPos)
local char = plr.Character or plr.CharacterAdded:Wait()
if charPos ~= char:WaitForChild("HumanoidRootPart").Position then
char.HumanoidRootPart.CFrame = charPos
end
end)
Detecting changes in the position property is dodgy to say the least, but heres an issue you didn’t account for:
Not only will the character still be desynced by the players ping (Remember, remote events aren’t instant) but the character would also be unable to move due to the server constantly thinking its in the same place, and would be teleporting the character back to the original location it was in.
In short, you cannot fix the desync, its just lag, a problem only fixable by the user and roblox themselves.
On your screen, your character will always appear to be ahead of where it is on the server, but everyone elses characters are “correctly” positioned, everyone gets desync and again, its an issue that only the user can fix by either getting a new ISP or moving closer to roblox servers.
I would imagine that with football/soccer games use both server and client detection for ball interactions, for example is player walks into the ball, the client tells the server and the server then checks if the player is close enough, if so the player has control of the ball.
Basically, to quickly put this into perspective, think of it like spaghetti pans.
If you are working on a line, it takes time for a pan to get a specific item,
(IE, noodles, sauce, ect…)
Depending on how long it takes for the pan to get to noodles, is something the server would think where you are depending on the packets you are sending to the server.
All characters for you are already synced for the serverside, so no matter where you move, both the server/other players see you update serverside only before showing their movements.
Lets also put this into perspective, a packet can take x time before it reaches a computer, so what you could also be percieveing is something x amount of MS ahead or behind of the server.
You are ALWAYS ahead of the server, but the server only shows where MOST recent movement packets of other players were sent.