✓ Accepted answer
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:
function onClicked ()
local player = game.Players.LocalPlayer
if player then
game:GetService("TeleportService"):Teleport(player, 283976037)
end
end
script.Parent.MouseButton1Down:connect(onClicked)
2 comments
Although that is one of the problems, take a look at the code again (hint: Line 7). :)
Yes, there's also that.