I’m having issues with detecting when a player is holding down R2 on console. FlamesActivated isn’t fired when a player holds down R2 on console. The event is fired when a player holds down their finger on mobile and their mouse on PC, but nothing happens on console. I am trying to use UserInputService to detect whether or not the player is holding down R2, but it isn’t working.
My Code:
local UserInputService = game:GetService("UserInputService")
local Players = game:GetService("Players")
local plr = Players.LocalPlayer
UserInputService.InputBegan:Connect(function(input)
local gamepad = Enum.UserInputType.Gamepad1
local button = Enum.KeyCode.ButtonR2
local char = plr.Character or plr.CharacterAdded:Wait()
if char:FindFirstChild("Flamethrower") and (UserInputService:IsMouseButtonPressed(Enum.UserInputType.MouseButton1) == true or UserInputService:IsGamePadButtonDown(gamepad, button) == true) then
game.ReplicatedStorage.FlamesActivated:FireServer()
end
end)
UserInputService.InputEnded:Connect(function(input)
local char = plr.Character or plr.CharacterAdded:Wait()
if char:FindFirstChild("Flamethrower") then
game.ReplicatedStorage.FlamesDeactivated:FireServer()
end
end)