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 6 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.

local ms = game:GetService("MarketplaceService")
local button = script.Parent.TextButton
local assetId = 997023296

button.MouseClick:Connect(function(Clicked)
   if Clicked then
       local plr = --???
       if plr then
          if ms:PlayerOwnsAsset(plr,assetId) then
             --Ranking player ???
          else
          end
       end
   end
end)

2 answers

Log in to vote
0
Answered by 6 years ago

Your code should be like this:

local Marketplace = game:GetService("MarketplaceService")
local Button = script.Parent.TextButton
local AssetID = 99702396
local RankLeaderstat = "Rank" -- Change to the name of the rank leader stat
local UpRankBy = 1

function RanlPlr(Player)
    local l = Player:WaitForChild("leaderstats")
    local r = l:WaitForChild(RankLeaderstat)
    r.Value = r.Value + UpRankBy
end

Button.MouseClick:connect(function(Player)
    if Makrketplace:PlayerOwnsAsset(Player, AssetID) then
        RankPlr(Player)
    else
        Player.Character:BreakJoints() -- Kill the Player since they don’t have the asset
    end
end)

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

local Marketplace = game:GetService("MarketplaceService")
local Button = script.Parent.TextButton -- Change this to your button
local AssetID = 99702396
local RankLeaderstat = "Rank" -- Change to the name of the rank leader stat
local UpRankBy = 1

function RankPlr(Player)
    local l = Player:WaitForChild("leaderstats")
        local r = l:WaitForChild(RankLeaderstat)
        r.Value = r.Value + UpRankBy
end

Button.MouseClick:connect(function(Player)
    if Marketplace:PlayerOwnsAsset(Player, AssetID) then
        RankPlr(Player)
    else
        Player.Character:BreakJoints() -- Kill the Player since they don’t have the asset
    end
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.

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

Answer this question