Donation GUI Help

Im trying to make a simple donation gui for my game and for some reason it isnt working.

Script:

local id = 950233042 

script.Parent.TextButton.MouseButton1Click:connect(function)
	game.MarketplaceService:PromptGameProductPurchase(script.Parent.Parent.Parent, id)

Whats wrong with it? Nothing is underlines in the studio so I dont think anything is wrong.

1 Like

Your syntax is wrong. You will want to keep your function declaration inside of the :Connect methods’ arguments. Also the function is called PromptProductPurchase not PromptGameProductPurchase

Here is pseuo-code:

local id = ...

MouseButton1Click:Connect(function()
    marketPlaceService:PromptProductPurchase(player, id)
end)

Also you may want to define your player by just using playersService.LocalPlayer rather than a large .Parent tree

1 Like

Thanks for the help. Not the best at scripting :sweat_smile:.

Your variable declaration is good. There are a few simple problems here. One this is that you forgot your end. Every event in Roblox needs an end to identify where it ends. You also forgot the bracket on the line where you declared your event. It should be:

script.Parent.TextButton.MouseButton1Click:connect(function()

The next problem is that there is no method called PromptGameProductPurchase. The method to prompt a developer product is called PromptProductPurchase. To find the name of all the methods, properties and events in Roblox, you can check out the developer hub.

Your new script should look like this.

local id = 950233042 

script.Parent.TextButton.MouseButton1Click:connect(function()
	game:GetService("MarketplaceService"):PromptProductPurchase(game.Players.LocalPlayer, id)
end)

You probably don’t have the output open because you didn’t know about the errors. If you didn’t know, the output shows you most of the errors that your scripts have. It also shows you the stack trace so it’s easy to spot. To open it you need to go to View and click Output.

Errors are marked in red
Warnings are marked in orange
You can even put your own text in there by using a
print("paste this into a script and magic")
image

3 Likes