Why is my surfaceGUI button not activating

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.

1 Like

Make sure the SurfaceGUI is inside the players GUI and the Adornee is on that part. Hope this helps

EDIT: Using .MouseButton1Click may work too? and if its a localscript in workspace. this wont work.

1 Like

There are a few things that could be causing this issue. Here are some possible things to check:

  1. 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)
  1. 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.
  2. 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.
  3. 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.
  4. 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.

chnage frame to button i,t will fix the thing

you cant active frame by clicking it it has to be button or something can be activated

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.