Tweenservice and/or animation making the player's model break on server side

I am making a vault system for a game. I use an animation for the animation and then tween the HumanoidRootPart to the other side of the barrier once the animation plays.

The problem happens sometime between the tween and the end of the animation on the server side. basically the HumanoidRootPart stays where it is supposed to but the rest of the character gets flung to a random place.

Server:

Local:

Server Script:

        hrp.Anchored = true
		hrp.CFrame = back.CFrame
		char.VaultScript.PlayAnim:FireAllClients()
		char.VaultScript.PlayAnim.OnServerEvent:Wait()
		local tween = TS:Create(hrp,info,{Position = front.Position})
		tween:Play()
		task.wait(.4)
		hrp.Anchored = false

local script:

local plr = game.Players.LocalPlayer
local char = plr.Character
local event = script:WaitForChild("PlayAnim")
local vault = script:WaitForChild("Vault")
local vaulttrack = char.Humanoid:LoadAnimation(vault)

event.OnClientEvent:Connect(function()
	vaulttrack:Play()
	vaulttrack.Stopped:Wait()
	event:FireServer()
end)

I’m pretty sure this has happened to me before, I don’t remember how I fixed it, but it also wasn’t as horrible as this.

You shouldn’t modify the player’s CFrame or physics from the server in any way because that is on their own jurisdiction (every player hold network ownership over their own character). Trying to interfere with it can cause unintended side effects, which could explain the problem you’re having. Try playing the tweening animation from a localscript.

Edit: Taking a look again, the issue seems to stem from you anchoring the HumanoidRootPart. All anchored parts automatically move to the server’s jurisdiction, so you can expect some fighting going on when you anchor a player model. Keep it off too I guess, or only anchor on the client side?

I moved the tween to the local side, however the problem now switched to the local side (with the server being completely fine). I also moved the anchoring to the local side, although whether or not the anchoring is on or off doesn’t have an effect. my guess it that the tween and the animation clash in some way but I couldn’t say how.

I did some testing, it seems like the problem is the tween. I tried switching on and off each part of the script and when it was just the tween, the humanoidrootpart moved without the other parts if the character. I’m just going to find another way to stop the player from moving once the humanoidrootpart gets teleported. I think the way to do this would be to move the humanoidrootpart first, and then make the animation just moving the character to there.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.