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

Team ranking system script isn't working any ideas why?

Asked by 7 years ago
game.Players.PlayerAdded:connect(function(plar)
    if plar:IsInGroup(3072854) then
        if plar:GetRankInGroup(3072854) >= 254 then
            plar.TeamColor = "Dark stone grey"
        else plar.TeamColor = "Medium stone grey"
        end
        else plar.TeamColor = "Bright green"
    end
end)

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

One of the problems is that you are comparing a BrickColor with a string.

print(BrickColor.new('White') == 'White')

This will print false.

You will need to either compare the name or the object e.g.

print(BrickColor.new('White') == BrickColor.new('White'))

-- or
print(BrickColor.new('White').Name == 'White')

Both methods will work

The second problem is that you cannot change the players team by setting the TeamColor. To change the team you can set the Team of the player to another Team object e.g:-

local tmSrv = game:GetService('Teams')

local blue = Instance.new('Team', tmSrv)
blue.TeamColor = BrickColor.new('Dark blue')
blue.AutoAssignable = false

local green = Instance.new('Team', tmSrv)
green.TeamColor = BrickColor.new('Lime green')
green.AutoAssignable = false

local teamList = {blue, green}
local teamCount = #teamList

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(charModel)
        -- randomly changes the team
        plr.TeamColor = teamList[math.random(teamCount)].TeamColor
    end)
end)

I hope this helps.

Ad

Answer this question