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

Auto ranking center? Button that rank player if the player own asset.

Asked by 7 years ago

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.

01local ms = game:GetService("MarketplaceService")
02local button = script.Parent.TextButton
03local assetId = 997023296
04 
05button.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
15end)

2 answers

Log in to vote
0
Answered by 7 years ago

Your code should be like this:

01local Marketplace = game:GetService("MarketplaceService")
02local Button = script.Parent.TextButton
03local AssetID = 99702396
04local RankLeaderstat = "Rank" -- Change to the name of the rank leader stat
05local UpRankBy = 1
06 
07function RanlPlr(Player)
08    local l = Player:WaitForChild("leaderstats")
09    local r = l:WaitForChild(RankLeaderstat)
10    r.Value = r.Value + UpRankBy
11end
12 
13Button.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
19end)

The code should be in a "Script" not a "LocalScript"

0
Okay! Thank you! (: I am still learning to script don't judge me. xD MelvinHjx 2 — 7y
0
Is it possible to make the player can't rank up if the player are a certain rank or above? MelvinHjx 2 — 7y
0
Nevermind is not working, I wonder if the player could get ranked up on the GROUP? Not on leaderstats. MelvinHjx 2 — 7y
0
There's a small typo in your function name. Eqicness 255 — 7y
View all comments (2 more)
0
Oh yeah, sos OMG_Gaming404 73 — 7y
0
The player cant get ranked up in the group as there is no way to do that OMG_Gaming404 73 — 7y
Ad
Log in to vote
0
Answered by
Eqicness 255 Moderation Voter
7 years ago
Edited 7 years ago

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:

01local Marketplace = game:GetService("MarketplaceService")
02local Button = script.Parent.TextButton -- Change this to your button
03local AssetID = 99702396
04local RankLeaderstat = "Rank" -- Change to the name of the rank leader stat
05local UpRankBy = 1
06 
07function RankPlr(Player)
08    local l = Player:WaitForChild("leaderstats")
09        local r = l:WaitForChild(RankLeaderstat)
10        r.Value = r.Value + UpRankBy
11end
12 
13Button.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
19end)

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.

0
He asked on how to rank someone on the group, not in leaderstats NurZwanzigBuchstaben 50 — 7y

Answer this question