SurfaceGui button refuses to activate

Hi, I’m trying to make a button on a gui that activates and fires a RemoteEvent. However, this button just does not want to activate. It has that thing when you hover over it and it becomes darker, so I know there’s nothing blocking it, yet pressing it does nothing. In fact, the button right next to it, with the same parent, works.

local RepStorage = game:GetService("ReplicatedStorage")
local BuyEvent = RepStorage:WaitForChild("BuyEvent")
local PlayerGui = game:GetService("Players").LocalPlayer.PlayerGui
local ValPriceLabel = PlayerGui:WaitForChild("buyValGui").Cost
local cornGui = PlayerGui.GameStats.Frame:WaitForChild("cornamountlabel")
script.Parent.Activated:Connect(function()
	print("Buy button pressed, firing signal")
	BuyEvent:FireServer()
end)
BuyEvent.OnClientEvent:Connect(function(ValPrice,cornStat)
	ValPriceLabel.Text = tostring(ValPrice).." Corn"
	cornGui.Text = tostring(cornStat)
end)

Try setting the parent of the SurfaceGUI to ScreenGUI and set it’s Adornee to the part you want.

Nope, didn’t work. Still don’t know why it won’t

1 Like

Do you have one script or two scripts

Replace:

script.Parent.Activated:Connect(function()

with

script.Parent.MouseButton1Click:Connect(function()

Make sure that the “script.Parent” refers to the Image/Textbutton.

1 Like

One script inside the button if that’s what you mean

Somehow even though I tried this before it works now, thanks!

1 Like

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