Button.MouseButton1Up not registering if the mouse exited the button


So I’m making a mobile slider for moving a car forwards or backwards and I’m listening for when the user pressed the slider and then depresses to stop moving the car. My problem is that what I’m using (Slider.MouseButton1Up) doesn’t fire if the finger/mouse exited the button before unpressing.

Does anybody know any other way to check if the finger that pressed the button then depressed even when it is out of the slider?


it shouldnt because MouseButton1Up only fires if it happens on the button

you can use MouseButton1Down to check when it starts, and use UserInputService to check if its released (will fire even if its not on the button)

You can make use of UserInputService

--// Services
local UIS = game:GetService("UserInputService")

--// Variables
local Button = script.Parent

--// State
local isHolding = false

--// Functions
local function Button1Down()
	isHolding = true
	print("Started Pressing Down")

local function InputEnded(input)
	if input.UserInputType == Enum.UserInputType.MouseButton1 then
		isHolding = false
		print("Stopped Pressing Down")

--// Connections

Edit: Just saw that @DeodorantSlice37 just suggested this same idea.

Hi, this is the exact issue. In the game, to make the car jump, you tap on the screen meaning that if you jump, the car would stop driving. I’m wondering if there is a way to detect all the taps and then track their position.

Ummm, have you tried the script I gave? I know it works it’s just a matter of if that’s what you were looking for. Which by your post seems like it is

Well it would work but if you would to release your tap somewhere else (which to make the car jump you have to press and release it would make the game think you stopped driving the vehicle which would be really annoying