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

How do you teleport players when they click a button?

Asked by
Japhie 20
10 years ago

I've looked at Youtube videos to try to help me in my struggle, and use their scripts, but none of them are working. Please help!

2 answers

Log in to vote
1
Answered by
Ekkoh 635 Moderation Voter
10 years ago

It'd probably go something like this, maybe it'll help you understand?

-- Declare a position to teleport to
local TeleportPos = Vector3.new(0, 5, 0)
local Btn = script.Parent -- Declare a variable for the button
Btn.ClickDetector.MouseClick:connect(function(PlayerWhoClicked)
    -- Teleport the Character of 'PlayerWhoClicked' to the Teleport Position 'TeleportPos'
    PlayerWhoClicked.Character:MoveTo(TeleportPos)
end)
0
This is what I was going for. Forgot to use Vector3 :P OniiCh_n 410 — 10y
0
When in doubt check the Wiki :) Ekkoh 635 — 10y
Ad
Log in to vote
0
Answered by
OniiCh_n 410 Moderation Voter
10 years ago

Maybe use the MoveTo function?

Something like

function tpPlayer()
however.You.Find.LocalPlayer:MoveTo(x, y, z) -- Idk how to find players on clicks; I'm not good with tables or GetChildren for the matter
end

script.Parent.ClickDetector.MouseClick:connect(tpPlayer) --assuming the script is within the button and there is a ClickDetector in it

This is really crappy code though. I made it on an iPad at school :P

0
Lol :P thanks for trying!!! Japhie 20 — 10y

Answer this question