Here is my code, It's on a surfaceGUI and teleports the player to another game, Works fine in Test mode as stated.
button = script.Parent
button.MouseButton1Down:connect(function ()
plrgui = button.Parent.Parent
player = plrgui.Parent
id = '411830270'
game:GetService('TeleportService'):Teleport(id, player)
end)

2 comments
is it a localScript?
It was a normal script, I changed it to local would not work in Test mode or Play mode