Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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"

6 comments

0

Okay! Thank you! (: I am still learning to script don't judge me. xD

0

Is it possible to make the player can't rank up if the player are a certain rank or above?

0

Nevermind is not working, I wonder if the player could get ranked up on the GROUP? Not on leaderstats.

0

There's a small typo in your function name.

0

Oh yeah, sos

0

The player cant get ranked up in the group as there is no way to do that

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.

1 comment

0

He asked on how to rank someone on the group, not in leaderstats

This discussion is preserved as it was. New answers, comments, and votes are closed.