Product not prompting in game

Fast forward a little bit and I’m making a donation place for my game. The prompting works in studio, but in the published game the prompt does not show up. Script:

local buttons : Frame = script.Parent.Buttons
local market = game:GetService("MarketplaceService")
local players = game.Players
players.PlayerAdded:Wait()
local player = players:GetChildren()[1]

local function onClick(button : TextButton)
	local id = button:GetAttribute("ID")
	market:PromptProductPurchase(player, id)
end

There’s not much more detail I can add, the button prompts the product purchase in studio, but not in game.

the problem was because the PlayerAdded:Wait() This waits for a new player to join before the script continues however in a published game this isn’t what you want because the player is already in the game

local buttons : Frame = script.Parent.Buttons
local market = game:GetService("MarketplaceService")
local players = game.Players
local player = players.LocalPlayer 

local function onClick(button : TextButton)
	local id = button:GetAttribute("ID")
	market:PromptProductPurchase(player, id)
end

If It’s not LocalScript You need remoteevent to send a signal to the server

2 Likes

Thanks! I’ll test it out and solution you if it works.