How to do I make my gamepass item appear when I buy the gamepass

I have a GravityCoilScript inserted in Workspace and I have a Local script inserted in the button that gives you the option to buy the Gamepass. The problem is that when I buy the Gamepass, the item does not appear for the player to use. Can anyone tell me what ive done wrong? I also inserted a GravityCoil inside of ServerStorage

Here is the GravityCoil Script:

Here is the LocalScript inside of the button:

you spelt .Parent wrong
image

1 Like

you should check the output window first

fixing the spelling error still did not work and the output is also saying that PlayerSpawned isnt a valid member of Players

Turn the part of

game.ServerStorage.GravityCoil:Clone()

into it’s own line, make it a local like this

local coil = game.ServerStorage.GravityCoil:Clone()

because putting the thing itself into the line does not provide the result.

you’re trying to use an event that fires when the player joins, use PlayerAdded

You have to listen for the event via PromptGamePassFinished, it won’t just fire the moment as soon as you purchase the weapon you need to connect it so that it’ll detect when to check:

local MPS = game:GetService("MarketplaceService")
local Players = game:GetService("Players")

local ID = 17640517

local function Spawned(Player)
    local HasGamepass = false

    local success, whoops = pcall(function()
        HasGamepass = MPS:UserOwnsGamePassAsync(Player.UserId, ID)
    end)

    if success and HasGamepass then
        local Tool = game.ServerStorage.GravityCoil:Clone()
        Tool.Parent = Player.Backpack

        local StarterTool = game.ServerStorage.GravityCoil:Clone()
        StarterTool.Parent = Player.StarterGear
    else
        warn("Checking if the Player has a Gamepass, more info: ", whoops)
    end
end

MPS.PromptGamePassPurchased:Connect(function(Player, ID, PurchaseCheck)
    if PurchaseCheck == true then
        local Tool = game.ServerStorage.GravityCoil:Clone()
        Tool.Parent = Player.Backpack

        local StarterTool = game.ServerStorage.GravityCoil:Clone()
        StarterTool.Parent = Player.StarterGear
    else
        warn("Something unexpectedly happened while detecting the purchase to the player")
    end
end)
Players.PlayerAdded:Connect(Spawned)
1 Like

i was just about to ask what that meant

1 Like