I've been trying to make this Teleporter for my Lobby that teleports into the actual game but it doesn't seem to work
It has to work like this "The player walks on the platform" "It has a countdown on like 20" "after those 20 seconds are gone the player should teleport but if the player walks off the platform it shouldn't teleport Anybody got an idea for what I'm missing? Thanks I'm still pretty new to scripting
debounce = false local TeleportService = game:GetService("TeleportService") local gameID = 4975499287 function onTouched(hit) if debounce == false then debounce = true print("Teleporter1 Touched") local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then wait(20) TeleportService:Teleport(gameID, player) end end script.Parent.Touched:connect(onTouched) script.Parent.TouchEnded:Connect(function() if debounce == true then debounce = false end end)
Hello, shark! Try using a function that waits 20 seconds and then teleports the player as the function won't stop running after a player walks off the part. Try this:
local debounce = false local TeleportService = game:GetService("TeleportService") local gameID = 4975499287 local function teleportPlayer(player) wait(20) TeleportService:Teleport(gameID, player) end local function onTouched(hit) if debounce == false then debounce = true print("Teleporter1 Touched") local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player then teleportPlayer(player) end end end script.Parent.Touched:Connect(onTouched) script.Parent.TouchEnded:Connect(function() if debounce == true then debounce = false end end)