As @HugeCoolboy2007 said, you would need to add the event that checks when the player buys it. I added that later, otherwise it would only give the money to the user after they rejoin.
You should keep the current code for when a player that already bought the gamepass rejoins, then add this code
local MarketplaceService = game:GetService("MarketplaceService")
local function gamepassPurchaseFinished(...)
-- give player money
end
MarketplaceService.PromptGamePassPurchaseFinished:Connect(gamepassPurchaseFinished)