So, I want to make an elevator in Roblox Studio, but I don't know how. I have buttons, and I want to make a click detector, so if someone clicks it the person gets teleported to a part. How can I do that?
✓ ANSWER ACCEPTED
How to create a teleport when clicked a button?
2 answers
✓ Accepted answer
You would put the click detector inside of the model you want the player to click and then you can also put a script inside that model and do...
script.Parent.ClickDetector.MouseClick:Connect(function(player)
local char = player.Character -- get character from player
char.HumanoidRootPart.CFrame = CFrame.new(x,y,z) -- enter your own coordinates
end)
You would insert a click detector into the button first. Since the goal is to teleport the character, you'll also have to change a body part's CFrame. Here's the code I would use:
detector = script.Parent:WaitForChild("ClickDetector")
detector.MouseClick:Connect(function(player)
player.Character.Torso.CFrame = CFrame.new(x,y,z) --change this to what you want
end)
Make sure to mark me as the answer if this helps, which I hope it does.
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
Thank you so much!
No problem man! if it helped would you mind accepting the answer?