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)
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"
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.