Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Why wont my gamepass script prompt a purchase?

local Remote = workspace:WaitForChild("BuyGamePet")
local ID = 7039978
game.Players.PlayerAdded:Connect(function(plr)
	Remote.onServerEvent:Connect(function()
		
		game:GetService("MarketplaceService").PromptGamePassPurchase:Connect(function(plr, ID)
	end)		
		
	end)
	end)

Error: ServerScriptService.PetGamePass:6: attempt to index field 'PromptGamePassPurchase' (a function value)

1 answer

✓ Accepted answer

Let's start with the mistakes you have made:

  1. No need for PlayerAdded event since you are receiving remote from the client
  2. OnServerEvent is how it should be written
  3. PromptGamePassPurchase is not an event

Solution:

local Remote = workspace:WaitForChild("BuyGamePet")
local ID = 7039978

Remote.OnServerEvent:Connect(function(Player)
    game:GetService("MarketplaceService"):PromptGamePassPurchase(Player,ID)      
end)

2 comments

0

Do I also need to use PromptGamePassPurchaseFinished to finish the transaction?

0

If you want to do something when they buy

This discussion is preserved as it was. New answers, comments, and votes are closed.