How do I make my gamepass button give gear?

I’ve already made the full GUI needed to purchase my gamepasses, and it prompts the purchase, but how do I make them give the gear?

I’ve added the two gear (boombox and gravity coil) to the replicated storage and now I’m wondering how to make the purchase give these items after rejoining.

2 Likes

When the player joins, you can check and see if they own the gamepass using UserOwnsGamePassAsync.

3 Likes

I see. I’ve tried using

local mps = game:GetService("MarketplaceService")

local gamepass_id = 0 --63172916

local plrs = game:GetService("Players")

game.Players.PlayerAdded:Connect(function(player)

if mps:UserOwnsGamePassAsync(player.UserId , gamepass_id) then

game.ServerStorage.ToolExample:Clone().Parent = player.Backpack

game.ServerStorage.ToolExample:Clone().Parent = player.StarterGear

end

end)

But I have multiple gear gamepasses, how will I differentiate between the two?

2 Likes

You’d make an if statement for each and add them accordingly. But it would be a bit easier to have a list of them with predefined Ids and items and all that.

2 Likes

you can use this to see when a gamepass is actually purchased in game
if they purchased it out of game you will want to do something like above to award it
could even use this in combination and just call a function to give the reward

https://developer.roblox.com/en-us/api-reference/event/MarketplaceService/PromptGamePassPurchaseFinished

3 Likes