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?
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.
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)```
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
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.