Hi,
My goal with the program was to increase FOV and change the cursor when right click is held, and revert it back when it is released to create an aiming effect with a gun. I did this using User Input Service’s InputBegan and InputEnded events. It works fine with InputBegan, but when I release right click, nothing happens. Using breakpoints I determined that it does register, however the if-statement says that the input argument is not right click, which is weird. Here is my code:
Code for input begin (this part works)
--v This code works fine v
UIS.InputBegan:Connect(function(input, gameHandledEvent)
if gameHandledEvent or not expectingInput then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 then
mouseDown = true
elseif input.UserInputType == Enum.UserInputType.MouseButton2 then
aiming = true
UpdateMouseIcon()
workspace.CurrentCamera.FieldOfView = 60
end
end)
Code for input ended (does not work)
--v This is where the issue is v
UIS.InputEnded:Connect(function(input, gameHandledEvent)
if gameHandledEvent then return end
--The left click release for shooting works
if input == Enum.UserInputType.MouseButton1 then
mouseDown = false
--The right click release for aiming does not get past this if-statement
elseif input == Enum.UserInputType.MouseButton2 then
aiming = false
UpdateMouseIcon()
workspace.CurrentCamera.FieldOfView = 70
end
end)
Any help/solutions would be greatly appreciated!