game.Players.PlayerAdded:connect(function(player) local leaderstats = Instance.new("IntValue") leaderstats.Name = "leaderstats" leaderstats.Value = 0 local rank = Instance.new("StringValue") rank.Name = "GroupRank" rank.Value = player:GetRoleInGroup(4012777) leaderstats.Parent = player rank.Parent = leaderstats local points = Instance.new("IntValue", leaderstats) points.Name = "ActivityPts" points.Value = 0 end)
I need to make this loop so that when you rank a player it'll imminently update their role on the leader board with out having to reset the game repeatedly.
Alright. You'd make a .Changed function for the Points variable, then make a conditional statement for that variable.
if points.Value > 50 then rank.Value = 'abcdefghijklmnopqrstuvwxyz' end if points.Value > 100 then rank.Value = 'kek' end
I say don't use elseif because it'd go bad fast. Since the points value will already be >50, the elseif won't even be reached.
More information will be added on request via edit.
EDIT: UPDATE!! SORRY THIS ANSWER IS WRONG! SEE BELOW!
So you mean the leaderboard to update when you change someone's rank in your group on the website?
There is no event that I know of that you can listen to. That means you can either: make an infinite while loop that updates the rank every x seconds.
while true do rank.Value = player:GetRoleInGroup(4012777) wait(10) end
or make a brick with a clickDetector with inside the clickdetector a script to update all players
script.Parent.MouseClick:Connect(function(p) for plr in pairs(game.GetService("Players"):GetPlayers()) do if plr:FindFirstChild("leaderstats") and plr.leaderstats:FindFirstChild("GroupRank") then plr.leaderstats.GroupRank.Value = plr:GetRoleInGroup(4012777) end end end
i just wrote these here by hand and didn't test, so it's just to get the idea. The last script is supposed to update all players on this server when you slick the brick with the clickdetector in it.
EDIT: UPDATE!! SORRY THIS ANSWER IS WRONG!
I just realised, reading the WIKI on GetRankInGroupID: "Using this in a Script, as opposed to a LocalScript, will not get you the most up-to-date information. If a player leaves a group while they are in the game, IsInGroup will still think they're in that group until they leave. However, this does not happen when used with a LocalScript." https://wiki.roblox.com/index.php?title=API:Class/Player/GetRankInGroup
That means, either you must call this in a localscript or Relog. The problem is that by calling this locally and sending the rank to the server you might allow exploiters to cheat, by telling the server a false rank. So there is no clean solution using GetRankInGroupID, as you must choose between convenience of use and level of security.
You might try if you are lucky if calling GetRankInGroupID for a player in a script after calling GetRankInGroupID locally for that player allows you to still get the updated value from the server (as a bug), but its an off chance.
If you wanna go further and implement a clean solution, don't start doing crazy things like asking other players or even other servers for a second opinion, use the webhook instead: http://wiki.roblox.com/index.php/Web_APIs#Group_APIs