Teleport to other games only works in private servers

I have a teleporter that teleports to another game, but for some reason it only works in private servers, I’ve checked the script, I am still learning Lua so maybe I missed something. Here’s the code:

local telePart = script.Parent

local TeleportService = game:GetService('TeleportService')

local placeID = 5641285560

local canTeleport = true

local function otherGame(otherPart)
	local player = game.Players:FindFirstChild(otherPart.Parent.Name)
	if player and canTeleport then
		canTeleport = false
		TeleportService:Teleport(placeID, player)
	end
end

telePart.Touched:Connect(otherGame)

Thanks in advance.

You’ve got the main basics down, there is just a couple errors that I noticed in your script, try this:

local telePart = script.Parent
local TeleportService = game:GetService("TeleportService")
local placeID = 5641285560
local canTeleport = true

local function otherGame(otherPart)
    local hum = otherPart.Parent:FindFirstChild(“Humanoid”)
    local plr = game.Players:GetPlayerFromCharacter(hum.Parent)
    if plr and canTeleport then
        canTeleport = false
        TeleportService:Teleport(placeID, plr)
        wait()
        canTeleport = true
    end
end)

telePart.Touched:Connect(otherGame)
1 Like

That didn’t work, maybe because I have it in a server script in a part?

You can’t get do GetPlayerFromCharacter(hum) with a humanoid. You need to use a Character in order to use this function. Try doing GetPlayerFromCharacter(otherPart.Parent) instead.

Made a little edit, see if it works now

Still didn’t work, I am not testing it in the games main place, I’m testing it in a test place, but I don’t think that would change anything.

You have to make sure that the starting place is public and you have to test it via roblox not studio

I’m not testing in studio, I’m testing in a test place via roblox which isn’t the starter place and the starter place is public. The test place is also public.

I found a YouTube video on how to do this exact thing (How to Teleport Players to a Different Roblox Game - Roblox Studio Tutorial - YouTube), and it works now!
Thanks for all the help btw.
If anyone was wondering here’s the working script:

local telePart = script.Parent
local TeleportService = game:GetService('TeleportService')
local placeID = 5641285560
local canTeleport = true

local function otherGame(otherPart)
	local player = game.Players:FindFirstChild(otherPart.Parent.Name)
	if player and canTeleport then
		canTeleport = false
		TeleportService:Teleport(placeID, player)
	end
end

telePart.Touched:Connect(otherGame)