Can I use :MoveTo on your character, if not, is there an alternate way of doing it?

So basically, I wanted to make your character move using a script, but it wouldn’t work and it never sent an error. I have been trying to find some other ways but it is on NPC only.

Is there an alternate way of doing this?

Example :

player.Character.Humanoid:MoveTo(pos)

Thanks, Vaelkarr.

Your example should work fine.

Could you post the code you tried using?

1 Like

I tried using

game.ReplicatedStorage.OnPressed.OnServerEvent:Connect(function(p)
      p.Character.HumanoidRootPart.CFrame = CFrame.new(408.5, 59.928, -408.57)
      p.Character.Humanoid:MoveTo(Vector3.new(348.56, 61.444, -409.55))
end)

Can you confirm this code does execute properly? If not, you could add a print statement at the top to make sure it fires.

Well, the player is getting teleported because of the second line, so I can confirm that it is firing.

You could try commenting out the first line to see if :MoveTo works at all

I tried that, it still printed, but it didn’t move my character.

1 Like

Does it work if you run :MoveTo client-sided?

I use this way:

local char = player.Character or player.CharacterAdded:Wait()
char:SetPrimaryPartCFrame(posCFrame)

Make sure to set the character’s PrimaryPart to its HumanoidRootPart, so the script would looks like this:

 local char = player.Character or player.CharacterAdded:Wait()
 char.PrimaryPart = char.HumanoidRootPart or char.Torso
 char:SetPrimaryPartCFrame(posCFrame)

You should probably freeze character movements before automatically moving the player. Or else they’ll cancel it.

However, I think client-sided moving method is not a biggie, honestly.


@Vozcom I don’t think that’s necessary, because the player fires a remote from client of some sort, thus the character should always exist after that.

I mean on your player character, not on an NPC character.