In my game, there is a growing pyramid, and players usually stand on it. It inserts new parts at the top (usually with players’ feet in them). Usually, players automatically go up, but when they have lag, their client doesn’t detect the new parts. When it finally appears, they glitch into the pyramid, since they skipped multiple blocks. How do I prevent players glitching into the pyramid?
Since safely moving models is easy enough to do with Model:MoveTo, you can use this while spawning parts to automatically move them on top of whatever they are on.
e.g.:
function BuildPyramid()
--build pyramid stuff
for _,player in pairs(Players:GetPlayers()) do
local char = player.Character
if char then
char:MoveTo(char.PrimaryPart.Position) -- essentially "move" them to the same spot as before
end
end
end
Note: This might cause players to backtrack to a previous position given where they were in the server compared to client-side, but you could solve this by calling :FireAllClients from a remote event in the script, and the clients just call :MoveTo on themselves since they have network ownership over their character.
I tried your solution, but my character kept glitching around and messing with things as I bumped into other players. Yes, I did use :FireAllClients().
You could also try moving parts down or just adding them to the bottom of the pyramid to solve the problem. It might not be very practical performance-wise for the first suggestion.
Give the pyramid a collision filter so that it doesn’t collide with itself. Make sure you’re moving these by CFrame. Spawn the next pyramid inside of the previous pyramid and move it up. At this point body movers should work as well or a tween. I’m not really familiar if a CFrame would cause the issue that you’re talking about in this scenario. But yeah if all goes right the new pyramid should be inside of the old one, and when it moves up the player should gradually be on top of it.