Touch Start/ Touch End for Image/Text buttons

Bit of an amateur question here, but when making a touch interface and I want to connect an event to when someone starts pressing the button and when someone stops, should I just use MouseButton1Down/Up, or is there a better way to handle this specifically for touch?

How about using InputBegan, InputEnded and InputChanged

1 Like

This. Connect to these UserInputService events and check for UserInputType.Touch.

This doesn’t work for my purposes, as it activates even if the player touched elsewhere on the screen, then slides their finger onto the button, which can result in accidentally clicking button while trying to perform other actions. Sorry, should have specified that at the start!

Sorry, use .InputBegan on the Button element (not UIS.InputBegan), Then on InputEnded just check that the touch originated on the button.

This is the case for Button.InputBegan, it will fire whenever the button is touched, regardless of where the touched start.

I think my only option is MouseButton1Down/Up, as I can’t see anything else in the API reference, but instinctively felt that there should be something dedicated to this, as using MouseButton1 events for a dedicated touch interface felt kinda hacky.

Aah, I understand now.

Yeah, making a dynamic touch UI is pretty hacky generally.

You could alternatively use .Activated & .InputEnded. I’m unsure if .Activated will have the same problem as InputBegan