Heyyo,

Anyone know how I'd go about making sure the same randomspawn doesn't gets picked twice? I was thinking I could put all the already selected spawns into a table, and then repeat randomspawn until it doesn't match something from the table...Seems like a really inefficient way of doing it though...I've done it in the past, but to be honest, I really do not remember how I did it.

Cheers.

function teleportPlayersToMap()
		local spawns = workspace[mapString].Spawns:GetChildren()
		
		for i, v in pairs(players) do
			local char = game.Workspace[v]
			if char then
				local randomspawn = spawns[math.random(1, #spawns)]
			end
		end
	end
	teleportPlayersToMap()

4 comments

1

you could take the already selected spawn and remove them from the table and then choose randomly

0

Thanks ! ;) Can't believe I didn't think of that though..

0

Also add math.randomseed(tick()) at the start so the random number sequence will never be the same.

0

I'm a bit late, but another (slightly more complicated) way of doing it is to copy whatever output you get to another table. Make a script that basically does this: "If the same output appears twice, delete the mose recent output and redo it." I don't know why I am commenting this, I am way too late and this is just making it harder to do. Regardless, I hope what I said makes sense to any of you.