Im trying to make a roleplay game and have been wanting to get the group ranks on the leaderboard but dont know how to make the script ive got 3 groups that need to be on there
step 1 - make a script into "ServerScriptService" since that is used for server scripts. step 2 - make sure it is a script and not a localscript or a modulescript. step 3 - copy the following code that contains explanations for the script, and paste it in the script.
game.Players.PlayerAdded:Connect(function(Player) --this means that a player was added into your game. It is called a function. local leaderstats = Instance.new("IntValue") --an intvalue (integer value) is something used for numbers. make sure "leaderstats" is named "leaderstats" just like tool handles. this is for the leaderboard. leaderstats.Name = "leaderstats" --make the name "leaderstats" so roblox recognizes it as a leaderboard. leaderstats.Parent = Player --make it inside the player, so they have their leaderboard. local Rank = Instance.new("StringValue") --this will be string value so that it adds the leaderstat to "leaderstats" Rank.Name = "Rank" --you can change the Rank to whatever name you want it. it can be "Group rank" or "Role" because the name is what it shows as the leaderstat. Rank.Parent = leaderstats --make it inside leaderstats, so roblox recognizes it as one of the leadertstats in the player. Rank.Value = Player:GetRoleInGroup(123456) --this will set the name of the players rank to the rank they are at. make sure to change the "123456" to what your group ID is. end)