MouseButton1Click not firing

I’m trying to make a button which triggers a RemoteEvent however whenever I click the MouseButton1Click do not fire. Why is this the case and what can I do to fix this?
.

Here's the script
local Rent = game:GetService("ReplicatedStorage").Customization.Rent

script.Parent.MouseButton1Click:Connect(function()
	
	print ("hi") -- Does not print when clicked
	
	Rent:FireServer(2)
	
end)

local button = script.Parent
local originalSize = button.Size

local originalPosition = button.Position

local scaleFactor = 1.05

local function onMouseEnter()
	local newOffsetX = originalPosition.X.Offset - (originalSize.X.Offset * (scaleFactor - 1) / 2)
	local newOffsetY = originalPosition.Y.Offset - (originalSize.Y.Offset * (scaleFactor - 1) / 2)

	button.Size = UDim2.new(originalSize.X.Scale * scaleFactor, originalSize.X.Offset * scaleFactor, originalSize.Y.Scale * scaleFactor, originalSize.Y.Offset * scaleFactor)

	button.Position = UDim2.new(originalPosition.X.Scale, newOffsetX, originalPosition.Y.Scale, newOffsetY)
end

local function onMouseLeave()
	button.Size = UDim2.new(originalSize.X.Scale, 0, originalSize.Y.Scale, 0)
	button.Position = UDim2.new(originalPosition.X.Scale, 0, originalPosition.Y.Scale, 0)
end

button.MouseEnter:Connect(onMouseEnter)
button.MouseLeave:Connect(onMouseLeave)

.

And here's the hierarchy and "proof" of the button being active

image

.
Notes:

  • The button is active
  • I have tried MouseButton1Down as well to no avail
  • Nothing is outputted into the output (including “hi”)

Is the button behind anything, perhaps a transparent frame being in front of the button? Or, it could be that image that’s parented to the button, maybe it’s covering up the entire button frame.

1 Like

Where is the localscript during runtime? Make sure it is a child of StarterPlayerScripts or a similar directory that will run them.

1 Like

I had a similar issue. Make sure that all of the Image Label’s inside of it have the active property set to false.
This could be a fix, maybe.

1 Like

It was behind another button so I copy + pasted the script inside of the other button and now it works!

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