Currently, I’m working on my game called Ultimate Lazer Tag and I’m trying to assign the players to either a Blue or Red team.
I used Region3 to find the players in a certain area and teleport them to the appropriate team / part.
– Heres the Code
– Finds players in Area
while gameHasStarted == false do wait(5) local partsInRegion = workspace:FindPartsInRegion3(Region2, nil, 1000) for i, part in pairs(partsInRegion) do if not debounce then debounce = true if part.Parent:FindFirstChild("Humanoid") then print("Player found in the region : " .. part.Parent.Name) print("Lets assign him to a team") local players_Team = addToTeam(part.Parent.Name) if players_Team == true then local char = part.Parent local Hrp = char:FindFirstChild("HumanoidRootPart") if Hrp then Hrp.Position = BluePart.Position end else if players_Team == false then local char = part.Parent local Hrp = char:FindFirstChild("HumanoidRootPart") if Hrp then Hrp.Position = RedPart.Position end end end end wait(10) debounce = false end -- debounce end end
–Assigns them to a team
function addToTeam(PlayerName) if (#BluePlayers < 6) then table.insert(BluePlayers, PlayerName) print(PlayerName .. " was put in the Blue Team") return true else table.insert(RedPlayers, PlayerName) print(PlayerName .. " was put in the Red Team") return false end end
For some reason the debounce doesn’t work. When I tested it with seven players, the region only registered one player and keep assigning him to one team.
I want the Region to find one player, assign him to a team, and then select another player and do the same.
I know a pause in between is necessary since the Region keeps selecting the same player over and over when he hasn’t been teleported yet.
Could anyone help provide some solutions ?