Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why doen´t this script teleport the player?

I have recently been making this script. It needs to teleport the player to a certain position however it doesn´t work.

script.Parent.MouseClick:Connect(function()
	local Pos = script.Parent.Parent.Parent.TeleportingBlock2
	game.StarterPlayer.StarterCharacter:MoveTo(Pos.Position)
end)

2 answers

✓ Accepted answer

Your script doesn't work because it's not moving the character.

StarterCharacter is a folder for objects to be placed inside of the actual character when it's loaded.

your actual movement command should look something like

game.Players.LocalPlayer.Character:MoveTo(Pos.Position)

Now, I must warn you that may act weird with replication, but this should get you on the right track.

1 comment

0

Thanks, it solved the problem.

The reason is that TeleportingBlock2 is an object. You need to get the position, to teleport to. Then you should use SetPrimaryPartCFrame()

script.Parent.MouseClick:Connect(function()
    local Position = script.Parent.Parent.Parent.TeleportingBlock2.Position
    game.Players.LocalPlayer.Character:SetPrimaryPartCFrame(Position)
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.