Learn How You Can Detect LeftMouseClick In Image

Here you learn how to detect click on ImageLabel

script.Parent.InputBegan:Connect(function(input)  -- assuming image property active is set to true and script placed inside ImageLabel
	if input.UserInputType == Enum.UserInputType.MouseButton1 then -- detects if pressed button is Left Mouse Button
		-- do that you want here
	end
end)

script type is local because i wanna detect for player which is running this script for.
I hope this guide you found useful or helpful.

3 Likes

im sorry what

2 Likes

Hey.

Not really sure what the point of this is, if you want to detect a click on an image you may as well use an ImageButtonā€¦

The code for a ImageButton is much simpler too.

script.Parent.MouseButton1Click:Connect(function()
	print("Clicked")
end)
1 Like

but if someone need to use ImageLabel instead

1 Like

There is no scenario where someone NEEDS to use an ImageLabel instead of an ImageButtonā€¦

1 Like

what the fart was your use case of needing to use imagelabels so bad that you made this

2 Likes

who need to use this, use. I dont care why.

1 Like

btw, i think this belongs in #resources:community-tutorials

(you can change categories by editing the message)

this is technically a tutorial since no actual object ā€œresourceā€ is being provided.

2 Likes

The point of #resources:community-resources is to provide resources that are yk, useful. This ā€˜resourceā€™ is totally pointless, with respect.

1 Like

Yeah, hence why I said the point of ā€˜#resources:community-resourcesā€™.

1 Like

actually, now that I think about it, this script also works under imagebuttons. why imagelabel specifically??

1 Like

Youā€™re guess is as good as mine, there would be no need for this script for an ImageButton either, as ImageButtons support straight up connecting to MouseButton1Click events- rather than getting InputBegan then checking what input it was.

2 Likes

The only reason I feel like anyone would want to do this is the mouse icon when hovering over an ImageButton.
image
Is there any way to remove this?

1 Like

Not sure, I guess thatā€™s where an ImageLabel would be better in this case.

1 Like

Well, I did end up using this method so it is indeed useful.

But I already know this soā€¦

1 Like

You can kind of get that icon fixed as well. Just set the ā€œActiveā€ property of the button to false and it removes the icon while hovering but it does still make it appear when you click it.

1 Like

This doesnā€™t support mobile or console users. Detect changes to GuiState or just use an image button instead.

3 Likes

you actually cooked!, keep these coming

You NAILED IT!! You should make More of the Related Bug-Fixes.

Not really a reason for this since you can just use image buttons, but this method can be used on frames and canvas groups too :smiley: (atleast as long as the ā€˜activeā€™ property is on i think.)

1 Like