Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I limit how many people can be teleported to a single brick?

Asked by 10 years ago

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

1 answer

Log in to vote
0
Answered by
MrFlimsy 345 Moderation Voter
10 years ago

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.

Ad

Answer this question