function onClicked () local player = game.Players.LocalPlayer if player then game:GetService("TeleportService"):Teleport(283976037, player) end end game.StarterGui.ScreenGui.TextButton.MouseButton1Down:connect(onClicked)
Honestly this is probably "my" first "complicated" script.....
Well first, you have the arguments inverted for the "Teleport" function. The "player" variable should be first, and the place id second. Like this:
function onClicked () local player = game.Players.LocalPlayer if player then game:GetService("TeleportService"):Teleport(player, 283976037) end end game.StarterGui.ScreenGui.TextButton.MouseButton1Down:connect(onClicked)
And as TheAlphaStigma pointed out, you're trying to set an event to something in the StarterGui service, which does not automatically update to individual players. You should use the ancestry chain of the script, by using the "Parent" property.
For example:
-- Also make sure this is a local script, since we're getting the LocalPlayer from the Players service. function onClicked () local player = game.Players.LocalPlayer if player then game:GetService("TeleportService"):Teleport(player, 283976037) end end -- Assuming this script is inside the TextButton GUI, this would work. script.Parent.MouseButton1Down:connect(onClicked)