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

How do i make it so when a player owns a gamepass then they get a badge? [closed]

Asked by 2 years ago

The badge id is 2125977058 and the gamepass id is 27455846

Closed as Not Constructive by JesseSong

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 2 years ago
local Players,mps=game.Players,game:GetService"MarketplaceService"
local BadgeService=game:GetService("BadgeService")

local function awardBadge(player)
    if not BadgeService:UserHasBadgeAsync(player.UserId,2125977058)then
        BadgeService:AwardBadge(player.UserId,2125977058)
    end
end
mps.PromptGamePassPurchaseFinished:Connect(function(player,gpid,wasPurchased)
    if wasPurchased and gpid==27455846 then
        awardBadge(player)
    end
end)
local function onPlayerAdded(player)
    wait()
    if mps:UserOwnsGamePassAsync(player.UserId,27455846)then
        awardBadge(player)
    end
end;Players.PlayerAdded:Connect(onPlayerAdded)
for _,v in ipairs(Players:GetPlayers())do 
    onPlayerAdded(v)
end;

Ad
Log in to vote
0
Answered by 2 years ago
Edited 2 years ago

For one, this isnt a website to request scripts being made for you.

But to achieve this, you would need to use MarketPlaceService to check whether the uses owns the gamepass and then use BadgeService to award it.