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

My script for team randomizer is not running at all. How would i fix this?

Asked by 4 years ago

Hello first off this is a alt account.

local Team_One = {game.Teams.Stalker}
local Team_Two = {game.Teams.Survivor}


function shuffle(arr) --This was stolen from another DevForum post. I cannot remember where I got it from.
    local arrCopy = {unpack(arr)}

    for i = 1, #arr do
        arr[i] = table.remove(arrCopy, math.random(#arrCopy))
    end
    return arr
end

local players = {}
for i,v in pairs(game.Players:GetPlayers()) do --Insert current players to table
    table.insert(players, v.Name)
end

local randomPlayers = shuffle(players) --Randomize players table

for i = 1, math.ceil(#randomPlayers/2) do --Take half of the random players and put them into team 1
    table.insert(Team_One, randomPlayers[i])
    print(randomPlayers[i],"is in Team stalker") -- Prints What team the player is in
    table.remove(randomPlayers, i)
end

for i, v in pairs(randomPlayers) do --Put the rest of the players into team 2
    table.insert(Team_Two, v)
    print(randomPlayers[i], "is in Team Two") --Prints what team the player is in
end
randomPlayers = {} --Reset table

So i have this placed in the ServerScriptService. And i have the 2 print in line 23 and 29. In the output it dose not print. It is a server script. Also i am new to scripting so i may not know what you mean. Thanks

0
Please specify your exact problem. Warfaresh0t 414 — 4y
0
The script is ot running when the game starts. I dose not randomize and it dose not print the line 23 and 29 toxitman2account -7 — 4y

Answer this question