Detecting if semi == true then detect 1 single mouse click, if its false detect while the mouse is down

Hi! I currently have some code that detects when the mouse is down, I need to detect if a value == true then it only detects 1 mouse click, but if its false it just detects while its down

Here is my current code

inputs.BindOnBegan("MouseButton1", nil, function() weapon:fire(true) end, "PewPew")
inputs.BindOnEnded("MouseButton1", nil, function() weapon:fire(false) end, "PewPewEnd")