Making a gui button that can be unclicked anywhere on the touch screen?

Greetings,

I am trying to copy the PUBG mobile system where you click on the throw button, then move the camera around with your finger and let go when you are ready nad it will throw despite your finger not being over the throw button.

Currently I am using the context action service to create a mobile button and am starting to be doubtful that it will be doable with that but can it be done with standard gui buttons instead? or some other way?

1 Like

Hello, better use usual ScreenGui and UserInputService.
To enable GUI for mobile users use “UserInputService.TouchEnabled”. It returns bool if user has enabled touch screen.
I never use ContextActionService for mobile adaptation, since it has limit with buttons and hard to set the position.

ye but can the button the player put his figner on the button then slide it across the screen to aim and then release to fire the bomb?

You can do next:

local Mouse = game.Players:GetMouse()
local Button =...

local Grenade_Button_Pressed = false
Button.MouseButton1Down:Connect(function()
   Grenade_Button_Pressed = true 
   while Grenade_Button_Pressed do
      --Insert loop to aim the grenade
   end
   --Throw the grenade
end)
Mouse.Button1Up:Connect(function()
   Grenade_Button_Pressed = false
end)```

what is this loop for aiming? the touch screen does not recognize my finger touching it after i touch the button

If touch screen doesn’t detect your finger, then try to make “fake” button. Use ImageLabel or TextLabel and detect if player touch the screen in area of those buttons

loop for aiming means when you throw the grenade, you choose the direction, and when you release your finger you should throw the grenade

brilliant idea good sir. Thank you kindly. Indeed the text label has all the same input events as buttons do with the added bonus of not interrupting camera movement input. This is exactly what I was looking for.