The script it suppose to play a sound if bought but its not working, I don't know why

ID = script.Parent.Text
local MarketplaceService = game:GetService("MarketplaceService")
local buyButton = script.Parent
local productId = 426543916
local player = game.Players.LocalPlayer
 



	
buyButton.MouseButton1Click:connect(function()
	MarketplaceService:PromptProductPurchase(player, productId)
	
	    for i, player in ipairs(game.Players:GetChildren()) do
             
	game.Workspace.Sound = ID

            end
        end)

3 comments

0

Not working isn't much of a help, can you give more detail?

0

i need the script when clicked the text button the id in the text box will be played when bought

0

Which part of it is not working? Is the purchase not showing up or is the sound not playing, or both?