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

How to detect changes in group role in real time?

Asked by 5 years ago

I need to detect changes in a person's role in the group in real time. I have no idea how to do this. This code below checks the rank, however when my group role changed, it receives the old rank and not my new rank screwing it all up. If I was Trainee, if I then change into Supervisor the script still thinks I'm a Trainee. How do I fix this?

function AutoUpdateRank(player)
    wait(1)
    print("ATTEMPT TO LOAD RANK!!!!" .. player.Name)
    while true do
        print("Checking RANK!")
        local newRank = player:GetRoleInGroup(3262436)
        print(player.Name .. "RANK: " .. newRank)
        if player:WaitForChild("leaderstats").Rank.Value ~= newRank then
            print("RANK CHANGED!!!!!")
        end
        player:WaitForChild("leaderstats").Rank.Value = newRank 
        wait(math.random()*10)
    end
end

game.Players.PlayerAdded:Connect(AutoUpdateRank)

for key, player in ipairs(game.Players:GetPlayers()) do
    AutoUpdateRank(player)
end
0
You are only firing the AutoUpdateRank when the player joins. mixgingengerina10 223 — 5y
0
You also can't concatenate name. remove the 2 dots after player at line 7 and line 3 and replace it with a "," mixgingengerina10 223 — 5y
0
Yes you can, but using multiple arguments is a lot easier thought User#19524 175 — 5y

Answer this question