In my minimap's there are 25 spawns. My problem is that there's a 1 in 25 chance of someone being spawned in the same place, and I'm trying to prevent this. How do I prevent no two people from spawning at the same spawn? Thank you!
function MovePlayers() local Players = game.Players:GetPlayers() local Spawnso = game.Workspace.Map.Spawns:GetChildren() for i, v in pairs(Players) do local ToSpawn = math.random(1, #Spawnso) if v.GameBool.Value == true then v.Character.HumanoidRootPart.CFrame = Spawnso[ToSpawn].CFrame * CFrame.new(0,5,0) v.Ingame.Value = true -- the last part is probably not needed but oh well wait(0.05) v.Character.Torso.Anchored = true end end end
You could make a table; once you spawn a player at a part, place that part inside the table, or move it to a different directory. You can check if that part is allready in the table, if it is, don't spawn the player there and retry. I personally would prefer moving the part to a different parent.