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

Random Team Separating script no working?

Asked by 8 years ago

The purpose of this script is to divide people evenly across 3 teams.
My Problem When ever trying to use this script it causes nothing to happen, and with no errors what so ever.

RequiredPlayers = 3
Teams={"VIP", "Guards", "Assasin"}

while true do
    player = game.Players:GetChildren()
    wait(1)
    if #player >= RequiredPlayers then
        Assign()
        break
    end
end

function Assign()
    local players = game.Players:GetChildren()
    for i = 1,#players do
        local ChosenTeam = Teams[math.random(1,#Teams)]

        players[i].TeamColor = game.Teams:FindFirstChild(ChosenTeam).TeamColor
        print("Teams Assigned")
    end
end

Thanks

0
There's nothing wrong with the script that I can see. Ensure that the script actually executes, and that you are attempting with at least 3 test players. Make sure you actually have those teams in game.Teams cabbler 1942 — 8y
0
For some reason the script doesnt seem to be executing? pluginfactory 463 — 8y

2 answers

Log in to vote
0
Answered by 8 years ago

Does it execute in studio mode? Or is it in play mode? IF it's in play mode press F9 and see what error you get

Ad
Log in to vote
0
Answered by 8 years ago

You put the infinite loop before the function itself means the script will never read it. Put the function before the infinite loop

Answer this question