I need help with a ranking center. So if a player have buyed a certain item the player will get ranked up on my group.
Here is what I have scripted so far.
01 | local ms = game:GetService( "MarketplaceService" ) |
02 | local button = script.Parent.TextButton |
03 | local assetId = 997023296 |
04 |
05 | button.MouseClick:Connect( function (Clicked) |
06 | if Clicked then |
07 | local plr = --??? |
08 | if plr then |
09 | if ms:PlayerOwnsAsset(plr,assetId) then |
10 | --Ranking player ??? |
11 | else |
12 | end |
13 | end |
14 | end |
15 | end ) |
Your code should be like this:
01 | local Marketplace = game:GetService( "MarketplaceService" ) |
02 | local Button = script.Parent.TextButton |
03 | local AssetID = 99702396 |
04 | local RankLeaderstat = "Rank" -- Change to the name of the rank leader stat |
05 | local UpRankBy = 1 |
06 |
07 | function RanlPlr(Player) |
08 | local l = Player:WaitForChild( "leaderstats" ) |
09 | local r = l:WaitForChild(RankLeaderstat) |
10 | r.Value = r.Value + UpRankBy |
11 | end |
12 |
13 | Button.MouseClick:connect( function (Player) |
14 | if Makrketplace:PlayerOwnsAsset(Player, AssetID) then |
15 | RankPlr(Player) |
16 | else |
17 | Player.Character:BreakJoints() -- Kill the Player since they don’t have the asset |
18 | end |
19 | end ) |
The code should be in a "Script" not a "LocalScript"
OMG_Gaming404's code is fine, but it has a few typos, here's a small revised version of the same exact code with no typos:
01 | local Marketplace = game:GetService( "MarketplaceService" ) |
02 | local Button = script.Parent.TextButton -- Change this to your button |
03 | local AssetID = 99702396 |
04 | local RankLeaderstat = "Rank" -- Change to the name of the rank leader stat |
05 | local UpRankBy = 1 |
06 |
07 | function RankPlr(Player) |
08 | local l = Player:WaitForChild( "leaderstats" ) |
09 | local r = l:WaitForChild(RankLeaderstat) |
10 | r.Value = r.Value + UpRankBy |
11 | end |
12 |
13 | Button.MouseClick:connect( function (Player) |
14 | if Marketplace:PlayerOwnsAsset(Player, AssetID) then |
15 | RankPlr(Player) |
16 | else |
17 | Player.Character:BreakJoints() -- Kill the Player since they don’t have the asset |
18 | end |
19 | end ) |
Edit: This is just a revised repost of OMG_Gaming404's code, this is NOT a way to change a player's group rank. I don't believe there is a way to change a user's group rank unless you have an external bot application.