Clickable button in SurfaceGUI

Hey! I’m trying to make a clickable button in surfaceGui but the click event doesn’t work. Anyone knows any alternative way to do this?

local PetsToDefeat = workspace.Pets_To_Defeat
local SFGUI = script.DropChance -- SurfaceGui

for _, Pet in ipairs(PetsToDefeat:GetChildren()) do
	if Pet:IsA("Model") then
		local MAIN = Pet.MAIN 
		local ClonedSF = SFGUI:Clone()
		local Button = ClonedSF.HealthGUI.Drop
		
		Button.MouseButton1Click:Connect(function()
			warn("Clicked")
		end)
		
		ClonedSF.Parent = MAIN
		ClonedSF.Adornee = MAIN
	end
end

4 Likes

Could you further elaborate on what you are trying to do, and what is happening, please? Thank you.

1 Like

You used warn(), which I think, disables the whole script…

Warn doesn’t disable the whole script, only error does. Not quite sure why warn is used here though.

They are trying to make a TextButton inside a SurfaceGui activate so it can output a warning. I don’t think a MouseButton1Click works for a surface GUI, and I’m not sure about activated.

2 Likes

Activate as in “affect the server” in some way? Or the TextButton be clickable?
(I agree that they should’ve used print() and not warn())

1 Like