TeleportService Script not functioning properly

Hello, my TeleportService script is not working:

local Players = game:GetService("Players")

local TeleportService = game:GetService("TeleportService")

local button = script.Parent

local gameID = 189707

button.MouseButton1Click:Connect(function(click)

local player = Players:GetPlayerFromCharacter(click.Parent)

if player then

TeleportService:Teleport(gameID, player)

end

end)

It throws the following error:
image

Pretty sure you can just use a local script

local Players = game:GetService("Players")

local player = Players.LocalPlayer

local TeleportService = game:GetService("TeleportService")

local button = script.Parent

local gameID = 189707

button.MouseButton1Click:Connect(function()

  TeleportService:Teleport(gameID, player)

end)

since MouseButton1Click has no params

I tried that, however I’ll try it again

@legspc Still not working, I even tried it with a RemoteEvent

Well any errors at all, any context why it might not

Nope, no errors

Nothing that I know of that is wrong

Publish the game and try it in the roblox player.

You do have AllowThirdPartyTeleports on, right?

Wait, I just realized Third Party Teleports were off. :man_facepalming:

I did turn it on, somehow it turned off.

If any of these answers were helpful to you, please mark it as the solution.

I turned ThirdPartyTeleports on, tried it in Roblox Player, still not working.

1 Like

Did you publish the game?

ignore

Hold on, would I be able to teleport to a game like Natural Disaster Survival, or does it have to be my own place?

It has to be a place in your game. I dont think you can just teleport to other games like Natural Disaster Survival.

Alright, I guess that’s the problem then. I’ll try making a place and seeing if it works then.

I’m pretty sure you can, though…

Do you have any idea what the problem could be then?

‘Teleporting’ in Roblox, describes the transportation of Players between different places and servers. TeleportService provides a range of functions allowing single or groups of users to be teleported. As Roblox games can contain multiple places, you can use the TeleportService to teleport players between different levels.

From TeleportService | Documentation - Roblox Creator Hub

I think you can only teleport between places in your game.