How to make players spawn randomly but also not spawn on the same spawn

I am trying to make the player not spawn on the same spawn but randomly at the same time, it works for spawning random but sometiems the player spawn on each other.

 local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
    	local AvailableSpawnPoints = SpawnPoints:GetChildren()
    	
    	for i, player in pairs(plrs) do
    		if player then
    			character = player.Character
    			
    			if character then
    				print(player.Name.." is about to be teleported")
    				character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[math.random(#AvailableSpawnPoints)].CFrame + Vector3.new(0,10,0)
end
2 Likes

Sorry for the crappy format but this should solve your issue.

 local SpawnPoints = ClonedMap:FindFirstChild("SpawnPoints")
    	local AvailableSpawnPoints = SpawnPoints:GetChildren()
    	
    	for i, player in pairs(plrs) do
    		if player then
    			character = player.Character
    			
    			if character then
    				print(player.Name.." is about to be teleported")
                                    local ind = math.random(#AvailableSpawnPoints)
    				character:FindFirstChild("HumanoidRootPart").CFrame = AvailableSpawnPoints[ind].CFrame + Vector3.new(0,10,0)
AvailableSpawnPoints[ind]:Destroy()
end
1 Like

um it still spawns the players inside each other?

1 Like

Assuming there are always at least as many spawns as there are players, remove the spawn from AvailableSpawnPoints when it is used.

character:FindFirstChild("HumanoidRootPart").CFrame = table.remove(AvailableSpawnPoints, math.random(#AvailableSpawnPoints)).CFrame + Vector3.new(0,10,0)

4 Likes

I know this was already solved, but why can’t you just place multiple spawnpoints?

He doesn’t want multiple players to spawn at the same point.

Ah, I see. That makes more sense!