function onClicked(click) local player = game.Players:GetPlayerFromCharacter(click.Parent) if player then game:GetService("TeleportService"):Teleport(116211000, player) end end script.Parent.MouseButton1Click:connect(onClicked)
I know the problem is in the line 2, show me what!
function onClicked() local player = script.Parent repeat player = player.Parent until player:IsA('Player') if player then game:GetService("TeleportService"):Teleport(116211000, player) end end script.Parent.MouseButton1Click:connect(onClicked)
Try this, it keeps going through the parents of the script until it reaches a player, then it will teleport them.
Please read this thread for how to use the TeleportService; http://wiki.roblox.com/index.php?title=TeleportService_Guide
And heres how you'd do it with a TextButton;
repeat wait(0)until game:FindService"Players"and game.Players.LocalPlayer and game.Players.LocalPlayer.Character and game.Players.LocalPlayer.Character:FindFirstChild"Humanoid"and game.Players.LocalPlayer:GetMouse()and game.Players.LocalPlayer:FindFirstChild"PlayerGui" script.Parent.MouseButton1Click:connect(function() if game:FindService("TeleportService")then game:GetService("TeleportService"):Teleport(116211000,game.Players.LocalPlayer) end end)
Hope this helped!