Help with player and Animations freezing on SetPrimaryPartCFrame()

Ok, so whenever I teleport my player to their highest checkpoint or the one they are at using SetPrimaryPart CFrame it works, but their Character flips sideways. All animations are stopped almost like the character just froze. Here is a video of the Character flipping and the script I Used:

local player = game.Players.LocalPlayer

local AtSpawn = false

script.Parent.MouseButton1Click:Connect(function()
	if AtSpawn == false then
		AtSpawn = true
		player.Character:SetPrimaryPartCFrame(game.Workspace.Checkpoints[1].CFrame + Vector3.new(0,3,0))
	else
		AtSpawn = false
		player.Character:SetPrimaryPartCFrame(game.Workspace.Checkpoints[player.leaderstats.Stage.Value].CFrame)
	end
	
end)

robloxapp-20220727-2106552.wmv (1.1 MB)

robloxapp-20220727-2108466.wmv (2.0 MB)

Any help is much appreciated!

1 Like

I Don’t exactly know how to fix your problem directly, but there is a workaround on how to teleport a player’s character just by setting the CFrame value of the character’s HumanoidRootPart part to a specified CFrame. This should work, assuming all of the character’s limbs are unanchored.

player.Character.HumanoidRootPart.CFrame = TargetPosition

1 Like

Ok so I figured it out I just changed SetPrimaryPartCFrame to MoveTo and that seemed to solve the problem here is the new script:

local player = game.Players.LocalPlayer

local AtSpawn = false

script.Parent.MouseButton1Click:Connect(function()
	if AtSpawn == false then
		AtSpawn = true
		player.Character:MoveTo(game.Workspace.Checkpoints[1].Position)
	else
		AtSpawn = false
		player.Character:MoveTo(game.Workspace.Checkpoints[player.leaderstats.Stage.Value].Position)
	end
	
end)