I’m making a donate board, where the player presses a text button on a part, then it prompts them to buy the developer product to donate. For some reason, though, the button won’t activate. here is my script:
local part = script.Parent
local frame = part:WaitForChild("SurfaceGui").Frame
local d5 = frame.Donate5
local d10 = frame.Donate10
local d25 = frame.Donate25
local d100 = frame.Donate100
local d1000 = frame.Donate1000
local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
d5.Activated:Connect(function(mouse)
print("d5 activated")
local plr = mouse.Parent
print(plr.name)
MarketplaceService:PromptProductPurchase(plr,19076165)
print("prompted")
end)
I don’t know if this is a problem, but there’s also a script that calls a function every time an input is ended, but I don’t know if that would interfere.
There are a few things that could be causing this issue. Here are some possible things to check:
Make sure that the Activated event is actually being fired. You can test this by adding a print statement to the event connection, like this.
d5.Activated:Connect(function(mouse)
print("d5 activated")
-- rest of the code goes here
end)
Make sure that the SurfaceGui object and its children (i.e., the Frame object and the Donate5 button) are properly parented to the part. If they are not properly parented, then the WaitForChild call on line 4 will return nil , and the rest of the script will not work.
Make sure that the Donate5 button is actually a button object and that it has the Activated event. If it is not a button or does not have the Activated event, then the script will not work.
Make sure that the MarketplaceService:PromptProductPurchase function is being called correctly. This function requires two arguments: a player object and a product ID. Make sure that you are passing in valid player and product ID values.
If there is another script that calls a function every time an input is ended, it is possible that this script is causing interference. Try disabling or modifying this script to see if it resolves the issue.
I hope this helps! Let me know if you have any other questions.