This is the code for the button in a GUI that should teleport the player to another place when clicked:
script.Parent.MouseButton1Click:connect(function()
game:GetService("TeleportService"):Teleport(24510429789)
end)
However when I click the button it says Teleport Failed: Cannot find game server. The ID I put in is definitely correct.

2 comments
must be linked to your game in game settings
It is, I've managed to teleport to the place before trying to use it in a GUI when I just did it when the player touched a part.