--When a player enters the game, I insert a Boolean Value into them and set it to false. When they step onto a pad, I set the Boolean value to true. Then before the round starts I compile a list of players that have a Boolean Value of true and teleport them into the round. It normally teleports all the players, but sometimes, a player is left behind. Is it some sort of timing problem or am I messing up the table? Thanks! Oh, I guess I should add, they can't step onto the pad until the current round is over in order to to join the next round.
--Script when they enter setting the Boolean value to false
function newPlayer(player) local SurvivorList = Instance.new("BoolValue") SurvivorList.Name = "SurvivorList" SurvivorList.Parent = player SurvivorList.Value = false end
--script inside the pad that sets the Boolean to true
debounce = false script.Parent.Touched:connect(function(hit) if debounce == false then debounce = true local plr = game.Players:GetPlayerFromCharacter(hit.Parent) if plr then local status = plr:FindFirstChild("SurvivorList") status.Value = true end wait(4) debounce = false end end)
--function compiling players for the round
function Compilesurvivors(v) for i, v in pairs(game.Players:GetChildren()) do if v.Name == survivors[i] then return else if v.SurvivorList.Value == true then table.insert(survivors, v.Name) end v.Character.Humanoid.HealthChanged:connect(function() died(v.Name, v.Character.Humanoid) end) end end end
--script where they are teleported into the round in the game
Compilesurvivors() wait(5) for i, v in pairs(survivors) do local player = game.Players:FindFirstChild(v) wait(1) if player then player.Character:MoveTo(Vector3.new(-74.166, 4.362, -14.037)) end end