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

Auto Team script according to group ranks not correctly working. Anyone?

Asked by
Mqanos 0
4 years ago
Edited by royaltoe 4 years ago

So I've made this

function onPlayerEntered(plyr)

if plyr:IsInGroup(5233740)>=10 then

plyr.TeamColor = BrickColor.new("Bright yellow")



elseif plyr:IsInGroup(5244884) then

plyr.TeamColor = BrickColor.new("Navy blue")



elseif plyr:IsInGroup(5235212) then

plyr.TeamColor = BrickColor.new("Crimson")



elseif plyr:IsInGroup(5246404) then

plyr.TeamColor = BrickColor.new("Really black")



elseif plyr:IsInGroup(5233740)<10 then

plyr.TeamColor = BrickColor.new("Cyan")

end

end

game.Players.PlayerAdded:connect(onPlayerEntered)



But won't work, I have a main group and 3 divisions, so I want when someone joins IF he is a HR in the main group to be teamed Bright yellow, if not check if he is in any of the three divisions and lastly to be teamed in the main group; and I managed to make it work 'till I added the ranks' matter (<= etc.) next to the ID... Can anyone do this for me?

1 answer

Log in to vote
1
Answered by 4 years ago

Hey Mqanos!

Try this script.You were only setting the team color :)

local teams = game:GetService("Teams")

game.Players.PlayerAdded:Connect(function(plr)
    if plr:IsInGroup(5233740) then
        if plr:GetRankInGroup(5233740) >= 10 then
            plr.Team = teams.Officers
            plr.TeamColor = teams.Officers.TeamColor
        else
            if plr:GetRankInGroup(5233740) >= 17 then
                plr.Team = teams.Headquarters
                plr.TeamColor = teams.Headquarters.TeamColor
            else
                plr.Team = teams.Enlisted
                plr.TeamColor = teams.Enlisted.TeamColor
            end
        end
    end

    if plr:IsInGroup(5244884) then
        plr.Team = teams["Div 1"]
        plr.TeamColor = teams["Div 1"].TeamColor
    end

    if plr:IsInGroup(5235212) then
        plr.Team = teams["Div 2"]
        plr.TeamColor = teams["Div 2"].TeamColor
    end

    if plr:IsInGroup(5246404) then
        plr.Team = teams["Div 3"]
        plr.TeamColor = teams["Div 3"].TeamColor
    end
end)
0
Works like a charm! Can't accept answear for a reason, there is only the report option, hm? Mqanos 0 — 4y
Ad

Answer this question