I am trying to make a teleporter that teleports the players on it every 23 seconds but it doesn't work properly. It waits 23 seconds before teleporting for the first time but after it will teleport players all the time. Can somebody help me please? ( i am kinda new to scripting) This is my code:
local TeleportService = game:GetService("TeleportService")
local gameID = 6446611098 -- Game ID
while true do
wait(23)
function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
TeleportService:Teleport(gameID, player)
end
end
script.Parent.Touched:connect(onTouched)
end

5 comments
Would appreciate if you accept when it helps
thanks! you helped me!
actually, it stopped working now. it just doesnt teleport me anywhere
Are there any errors?
When there is 1 error the loop can break forever