How could this be rewritten to be more smooth and consistent during a game? Sometimes it works and other times it is really delayed (5-10 seconds)
-- function onTouched(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
wait(.01) if player then
game:GetService("TeleportService"):Teleport(4761345992,player)
end
end
script.Parent.Touched:connect(onTouched)
There isn’t much you can do to fix this unfortunately. Maybe try to create a less awkward wait, perhaps make a frame appear on screen saying “TELEPORTING - PLEASE WAIT”.
A major glaring issue I see here is that your script is teleporting a user every time they register .Touched, which could be like 10 times in less than a second, I’m sure TeleportService has something to combat this, but it just doesn’t seem right to me.
As others have mentioned, TeleportService is inconsistent, breaks a lot, and should overall be avoided whenever possible.