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

How am supposed to specify who to teleport in this GUI?

Asked by 10 years ago

Okay i have a Main Menu Gui.. In it, it has 4 text buttons, only 3 teleport the player. I want the buttons to teleport players to one of my universes or places within my game once they click the textbutton. But this is what happens, In studio when i try to test the button it says Teleporting players in roblox studio is not permitted. So im saying yay i guess it works... No, When i try to play my game from the website it doesn't teleport people at all.

---------------------- HERES THE SCRIPT -------------------------------- plr = script.Parent.Parent.Parent.Parent

script.Parent.MouseButton1Click:connect(function() game:GetService('TeleportService'):Teleport(143510844,plr) end)

People where telling me i need to specify who needs to get teleported. How do i do that? :/ Please help``

2 answers

Log in to vote
1
Answered by 10 years ago

Make the script a localscript. Do not attempt to teleport the character, since that'll result in an error:

wait()
local plr = game.Players.LocalPlayer
-- MouseButton1Click is for clickdetectors, not textbuttons
script.Parent.MouseButton1Down:connect(function() game:GetService('TeleportService'):Teleport(143510844,plr)
end)
--[[ The error that says "Teleporting players in roblox studio is not permitted." means you can't teleport to other places in studio.]]
Ad
Log in to vote
0
Answered by
52M 10
10 years ago

Change the script into a LocalScript then put this into it.

plr = game.Players.LocalPlayer.Character

script.Parent.MouseButton1Click:connect(function() 
game:GetService('TeleportService'):Teleport(143510844, plr) 
end)

Answer this question