Teleportation Issues

Attempting to make a script that teleports a player to a given location.

local SLPos = workspace.SettlerLobby.SettlerLobbyPos
local SLButton = workspace.TeamLobby.TB1.Button.ButtonGui

SLButton.MouseButton1Click:Connect(function()
    game.Players.LocalPlayer:moveTo(SLPos.Position)
end)

When I try clicking the button it says “moveTo is not a valid member of Player”. How would I go about teleporting the player, is moveTo not a real thing?

You have to do game.Players.LocalPlayer.Character:MoveTo(SLPos.Position). You are moving the character, not the player.

1 Like

Well, it worked, but the player isn’t rotated like the part is. Is there a way to rotate the player so he’s facing the camera?

Rotation cannot be set when using MoveTo as the method only accepts a Vector3 parameter for the position.

Instead, you’ll want to use SetPrimaryPartCFrame so you are able to pass rotation data.

game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(SLPos.CFrame)
3 Likes

Hello. You could try changing the player’s character’s primary part CFrame:

game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(SLPos.CFrame)

In this case, you will have to adjust the Y component of the position or just place the part a bit upper.

Perhaps this post holds the key? How to rotate a player using CFrame. This appears to be very similar. As @mishajones said, CFrame should work.

You have to get the character thats located in the workspace, and then CFrame the LowerTorso (Or Torso if your using R6) to the part’s CFrame

https://developer.roblox.com/en-us/api-reference/datatype/CFrame