Can't move player's torso

Hello. I am trying to make a checkpoint system in my obby. In the script, I am not able to change the position of the player’s torso. It isn’t giving me any errors either.
Here’s what it does.


I had tried searching, but it didn’t bring me anywhere.

This is the script. It is in ServerScriptService.

local Players = game.Players

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local Stage = player:WaitForChild("leaderstats"):WaitForChild("Stage")
		character.Torso.Position = game.Workspace.Checkpoints:FindFirstChild(tostring(Stage.Value)).Position
	end)
end)

I had also tried to use :MoveTo on the character’s model but that didn’t work either.

The problem might be that the script is running before the character is fully initialized within the physics engine. When the character is added, you should wait one physics frame before manipulating the position of the character position, otherwise the server will override any changes you make. To wait one physics frame, just call RunService.Heartbeat:Wait()

Also instead of changing the character’s torso’s position, I would change its CFrame instead, or use :MoveTo on the character model as you said you tried before.

My solution using :MoveTo

local Players = game.Players
local RunService = game:GetService("RunService")

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		RunService.Heartbeat:Wait()
		character:MoveTo(game.Workspace.Checkpoints:FindFirstChild(tostring(Stage.Value)).Position)
	end)
end)

the RunService.Heartbeat:Wait() ensures a physics frame completes and initializes the character model before you try to manipulate its position.

Hope this helps!

Edit: removed my test example and replaced it with code found in OP’s script

It’s working now. Thanks a lot!

1 Like

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