I've made a script to prompt the owner if it has not enough money to buy anything, and it prompts the player to buy 10 000$. He can decide if he wants to get the offer with robux or tix. I've made it to prompt the purchase when it click one of the buttons:

local productId = 21314865
 
game.Players.LocalPlayer.PlayerGui:WaitForChild("NotEnoughMny").Frame.mnyR.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId, true, 1)
end)

game.Players.LocalPlayer.PlayerGui:WaitForChild("NotEnoughMny").Frame.mnyT.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId, true, 2)
end)

The parenting is correct. But... it just works the first time. Or else, the first time i GUI them, it works fine, but when it goes the second, third and continuing gui, it dont work. Why?

EDIT: I just picked up an while loop to make the values wait for the child multiple times, so here it goes the corrected script for who wants:

local productId = 21314865
 
while true do
	game.Players.LocalPlayer.PlayerGui:WaitForChild("NotEnoughMny").Frame.mnyR.MouseButton1Click:connect(function()
		game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId, true, 1)
	end)
	wait()
	game.Players.LocalPlayer.PlayerGui:WaitForChild("NotEnoughMny").Frame.mnyT.MouseButton1Click:connect(function()
		game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, productId, true, 2)
	end)
	wait()
end

1 comment

0

omg...