How to make buttons not activate when being dragged over

I have a gui button that only appears on mobile, and while testing I noticed it often gets activated by dragging over it to adjust the camera. here is an example:

as you can see, when I drag my mouse over the button it activates, and the same thing happens on mobile. I do not want this to happen, how can I make the button only activate when pressed, not when dragged over?

You could check that the button pressed and released positions are over top of the button when those events trigger.

yes, but the problem is that the press and release positions are on it as it only fires when you hit it, not when you start dragging.

Sorry, I’m a bit confused. Isn’t that what you want? For the button to be activated only when you press/hit the button?

If you are using MouseButton1Down, use MouseButton1Click.

I am actually using this custom replacement for ContextActionService, (here is a Link!) I looked through it and it does not use mouse button down or mouse button click, as it is a server sided module. I am gonna try to modify it so that it does use click, but if I remember correctly click only fires when you press down and release. This will cut down on the false positives, but I do not think it will fully eliminate them as there is still a chance someone drags onto it and releases on it as well. Plus, I use user input began and end in the script for denounce and to make it change color when the input begins, won’t using mouse button click affect this and make it only fire once, on user input end?

The problem is that when the player drags onto it their mouse position is on it, even though before it was not. The problem I’m getting is not that it fires while dragging, it’s that when adjusting your camera on mobile you often drag into it, which causes it to fire.

Oh I see. I don’t know the answer to this off the top of my head, so maybe someone else more knowledgeable can help you out with this.

local UIS = game:GetService("UserInputService")
local button = script.Parent

button.MouseButton1Click:Connect(function()
	if UIS.TouchEnabled then --end function if player is on a touchscreen device
		return
	end
	--perform normal button action here when mouse clicked and released
end)

button.TouchTap:Connect(function()
	--perform normal button action here when screen is tapped and released
end)

I added comments, should make everything obvious.