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

How do I fix these auto rank scripts?

Asked by 2 years ago

Hey Fellow scripters, I would like to see why my auto rank scripts aren't working.

Visitor Auto Rank:

function onPlayerEntered(plr)
    if plr:GetRankInGroup(15291764) ==0 then
plr.TeamColor = BrickColor.new("Pearl")
plr:LoadCharacter()
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

Personnel Auto Rank:

function onPlayerEntered(plr)
    if plr:IsInGroup(15291764) and plr:GetRankInGroup(15291764) >= 1 and plr:GetRankInGroup(15291764) <= 242 then
plr.TeamColor = BrickColor.new("Bright violet")
plr:LoadCharacter()
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

OIG Auto Rank:

function onPlayerEntered(plr)
    if plr:IsInGroup(15291764) and plr:GetRankInGroup(15147821) >= 243 and plr:GetRankInGroup(15147821) <= 252 then 
plr.TeamColor = BrickColor.new("Sea green")
plr:LoadCharacter()
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

JAG Auto Rank:

function onPlayerEntered(plr)
    if plr:IsInGroup(15147906) and plr:GetRankInGroup(15147906) >= 1 and plr:GetRankInGroup(15147906) <= 253 then
plr.TeamColor = BrickColor.new("Burgundy")
plr:LoadCharacter()
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

NCIS Auto Rank:

function onPlayerEntered(plr)
    if plr:IsInGroup(15240066) and plr:GetRankInGroup(15240066)  >= 1 and plr:GetRankInGroup(15240066) <=14 then
plr.TeamColor = BrickColor.new("Crimson")
plr:LoadCharacter()
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

HQ Auto Rank:

function onPlayerEntered(plr)
    if plr:IsInGroup(15291764) and plr:GetRoleInGroup(15291764) >= 243 then
plr.TeamColor = BrickColor.new("Gold")
plr:LoadCharacter()
end
end

game.Players.PlayerAdded:connect(onPlayerEntered)

The rank structure in most of these scripts are

(Regimental Ranks) Then (HQ Ranks)

Refering to see if they are in the regimental group then if they are and their rank is above 1, and under a certain rank id which would be HQ then they get rank to another team.

Although when I join the HQ Team is empty and I am in the personnel team.

Can anyone suggest a fix?

2 answers

Log in to vote
0
Answered by
MattVSNNL 620 Moderation Voter
2 years ago
Edited 2 years ago

I made an automated script for you, I can't exactly tell what you want so I just looked at your code identifying what you are trying to do!

Hope this works if it does, I'd appreciate if you accept my answer if not, comment the error or problem

It's all one script!

Script: SERVERSCRIPT

local PlayersService = game:GetService("Players")

local rankIds = {
    ["Visitor"] = 0; -- Change id to your rank id
    ["Personnel"] = 0; -- Change id to your rank id
    ["OIG"] = 0; -- Change id to your rank id
    ["JAG"] = 0; -- Change id to your rank id
    ["NCIS"] = 0; -- Change id to your rank id
    ["HQ"] = 0; -- Change id to your rank id
}

local rankColors = {
    ["Visitor"] = BrickColor.new("Pearl");
    ["Personnel"] = BrickColor.new("Bright violet");
    ["OIG"] = BrickColor.new("Sea green");
    ["JAG"] = BrickColor.new("Burgundy");
    ["NCIS"] = BrickColor.new("Crimson");
    ["HQ"] = BrickColor.new("Gold");
}

local groupId = 0 -- Change id to your group id

PlayersService.PlayerAdded:Connect(function(player)
    if player:IsInGroup(groupId) then

        print(player.Name.." is in the group!")

        for rankName, rankId in pairs(rankIds) do
            if player:GetRankInGroup(groupId) == rankId then

                player.TeamColor = rankColors[rankName][2]

                player:LoadCharacter()

            end
        end

    end
end)
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question