There’s a way to prevent a touch function activate when pressing the jump button ou using the analog?
The Script:
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local tool = script.Parent
local UserInputService = game:GetService("UserInputService")
local RocketModule = require(script.Parent:WaitForChild("RocketModule"))
local Char = game.Workspace:WaitForChild(plr.Name)
local debounce = false
local function OnActivated()
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
if debounce == false then
debounce = true
RocketModule.Fire(Mouse.Hit.p, Char)
local ServerPart = game.ReplicatedStorage:WaitForChild("RocketFired"):InvokeServer(Mouse.Hit.p, Char)
ServerPart:Destroy()
wait(2)
debounce = false
end
end
end)
end
tool.Equipped:Connect(OnActivated)
The issue is when I press the analog to move the character on mobile and then the touch function process it, while i want it to only process when not touching these buttons.
local plr = game.Players.LocalPlayer
local Mouse = plr:GetMouse()
local tool = script.Parent
local UserInputService = game:GetService("UserInputService")
local RocketModule = require(script.Parent:WaitForChild("RocketModule"))
local Char = game.Workspace:WaitForChild(plr.Name)
local debounce = false
local function OnActivated()
UserInputService.InputBegan:Connect(function(input, gameProcessed)
if gameProcessed then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 or input.UserInputType == Enum.UserInputType.Touch then
if debounce == false then
debounce = true
RocketModule.Fire(Mouse.Hit.p, Char)
local ServerPart = game.ReplicatedStorage:WaitForChild("RocketFired"):InvokeServer(Mouse.Hit.p, Char)
ServerPart:Destroy()
wait(2)
debounce = false
end
end
end)
end
tool.Equipped:Connect(OnActivated)
I added a check for gameProcessed.
As the DevHub says:
gameProcessed indicates whether the game engine internally observed this input and acted on it. Generally this refers to UI processing, so if a button was touched or clicked from this input, gameProcessed would be true.