My Teleport to another game script isn't working

Hello! I’m Koala_Helper. I want to achieve making a part that once touched, it will teleport players to a different game I made within the place. (Multi place game)


The issue is that the scripts I’ve tried aren’t working,




I’ve tried three different scripts and one is from the developer hub, none of them have worked. This is the post on the dev hub I read: Teleporting Between Places

The scripts I’ve tried are:

--This is from the dev hub.
local TeleportService = game:GetService("TeleportService")
 
local placeID_1 = 408502340
local placeID_2 = 408502380
 
local function onPartTouch(otherPart)
	local player = game.Players:GetPlayerFromCharacter(otherPart.Parent)
	if player then
		TeleportService:Teleport(placeID_1, player)
	end
end
script.Parent.Touched:Connect(onPartTouch)

--This one worked but most of the times it just crashes the game. It doesn't really work well.
local TeleportService = game:GetService("TeleportService")

local Place = 5415764538

 

script.Parent.Touched:connect(function(hit)

local player = game.Players:GetPlayerFromCharacter(hit.Parent)

if player then

TeleportService:Teleport(Place, player)

end

end)
``
<br>

```lua
--The last script I tried.



local TeleportService = game:GetService("TeleportService")
local gameID = 5415764538 -- Put your game ID here.--  
 
function onTouched(hit)
    local player = game.Players:GetPlayerFromCharacter(hit.Parent)
    if player then
        TeleportService:Teleport(gameID, player)
    end
end
 
script.Parent.Touched:connect(onTouched)

Does anybody know what I did wrong?

Add a debounce in this script and it should be fine.

3 Likes

Okay! Thank you so much, I’ll try that.

Thank you so so much, I’ve literaly tried for so long and now it finaly works!