In my game I have everyone in the server teleport to one of 20 different teleporter bricks.
Now, everyone teleports at random but sometimes people are teleported to the same brick which is a problem. How could I change this script to check and make sure no two people are sent to the same brick?
Thanks for any help you give!
tele = teles[math.random(1,#teles)] x1 = tele.Position.X-(tele.Size.X/2) x2 = tele.Position.X+(tele.Size.X/2) z1 = tele.Position.Z-(tele.Size.Z/2) z2 = tele.Position.Z+(tele.Size.Z/2) obj.Character.Torso.CFrame = CFrame.new(math.random(x1,x2),tele.Position.Y+5,math.random(z1,z2)) balanced = false else
When a player teleports, remove the corrosponding teleporter from the table using table.remove
. After everyone is teleported, re-add all the teleporters to the table.