Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I teleport a character to a block?

Asked by
Bman8765 270 Moderation Voter
9 years ago

I have this current code

function ClickedCourse1()
    Course1.Visible = false
    Course2.Visible = false
    Course3.Visible = false
    CourseSelect.Visible = false

end

Basically when I click a button it disables all the GUI's but I always want it to teleport the player to a block named Course1Tele I just want to know the simple command on how to do this, thanks!

2 answers

Log in to vote
0
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

You can either change the CFrame of a character's torso, or use the MoveTo() method on the character model itself. Of course, you have to have a way to get the character.

character:MoveTo(workspace.Course1Tele.Position)
character.Torso.CFrame = CFrame.new(workspace.Course1Tele.Position)
Ad
Log in to vote
0
Answered by
Nymint 85
9 years ago

With .MouseButton1Down Event or A LocalPlayer (if your script is a LocalScript) all you gotta do is locate the Character's Torso from the player and change its CFrame equalized to the block's CFrame.

local Brick=Workspace.Part

function Teleport(player)
if player.Character:FindFirstChild("Torso") then
player.Character.Torso.CFrame=Brick.CFrame
--Model:MoveTo(x,y,z) can do this too, but I prefer it this way.
--If you want the player to stand on the brick this is how you'd do it (I think.):
player.Character.Torso.CFrame=Brick.CFrame*CFrame.new(0,Brick.Size.Y,0)
end

script.Parent.MouseButton1Down:connect(Teleport(player))

Answer this question