I know I can teleport 1 player at a time with this block of code:
local TeleportService=game:GetService("TeleportService") local Place=1651711943 script.Parent.Touched:connect(function(hit) local player=game.Players:GetPlayerFromCharacter(hit.Parent) if player then TeleportService:Teleport(Place, player) end end)
But how do I do it with multiple people at a time and that needs that number of people?
local TeleportService=game:GetService("TeleportService") local Place=1651711943 script.Parent.Touched:connect(function(hit) for i, player in ipairs(game.Players:GetChildren()) do TeleportService:Teleport(Place, player) end end)
thats to tp everyone at once now the other part i think u meant how to teleport a certain number of people ?
local TeleportService=game:GetService("TeleportService") local Place=1651711943 local numtp=3 script.Parent.Touched:connect(function(hit) while numtp >0 do for i, player in ipairs(game.Players:GetChildren()) do TeleportService:Teleport(Place, player) numtp = numtp-1 end end end)
I think this is what l_337 was trying to do
local TeleportService=game:GetService("TeleportService") local Place=1651711943 local numtp=3 script.Parent.Touched:connect(function(hit) for i, player in ipairs(game.Players:GetChildren()) do if numtp > 0 then TeleportService:Teleport(Place, player) numtp = numtp-1 end end numtp=3--resets numtp so that you can tp 3 more people next time it is touched end)