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

Team Randomizer Doesn't Work?

Asked by
Rurith 10
10 years ago

The Randomizer part itself I think works, but the feature that makes it usable by the group is broken, I think. If you could fix it that would be great! THANKS!

TeamOne = 0
TeamTwo = 0

TeamColorOne = "Bright red" 
TeamColorTwo = "Bright blue"

CanChat = true

local Administrators = {"Rurith"}
local GroupID = 954478
local GroupRankPermission = 11

local RunText = "!run/"

game.Players.ChildAdded:connect(function(Player)
Player.Chatted:connect(function(Chat)
local HasAdministrators = false
for i = 1, #Administrators do
if Player.Name == Administrators[i] then
HasAdministrators = true
break
end
end

if HasAdministrators == false and Player:IsInGroup(GroupID) and Player:GetRankInGroup(GroupID) >= GroupRankPermission then
HasAdministrators = true
end

function onChat(Chat)
if Chat:lower():sub(1,RunText:len()) == RunText then
TeamOne = 0
TeamTwo = 0
if CanChat then
CanChat = false
Get = game.Players:GetChildren()
for i = 1,#Get do
wait(0.1)
RanNum = math.random(1, 2)
if RanNum == 1 then
if TeamOne <= TeamTwo + 1 then
Get[i].TeamColor = BrickColor.new(TeamColorOne)
TeamOne = TeamOne + 1
end
end
if RanNum == 2 then 
if TeamTwo <= TeamOne + 1 then
Get[i].TeamColor = BrickColor.new(TeamColorTwo)
TeamTwo = TeamTwo + 1
end
end
end
CanChat = true
end
end
end

function onEnter(NewPlayer)
NewPlayer.TeamColor = BrickColor.new("White")
for _,v in pairs(Administrators) do
if NewPlayer.Name == v then
NewPlayer.Chatted:connect(onChat)
end
end 
end

game.Players.PlayerAdded:connect(onEnter)

Answer this question