I’m currently making a magnum revolver for my game. Right now I haven’t begun scripting but in the brainstorming I was trying to figure out how I would check if the player has held the mouse for a certain amount of time.
Example of what i want to achieve:
(TIME STAMPED)
cred: Adjo on youtube
What i want to achieve:
Check if player holds mouse for x amount of seconds, then shoot
Instead of resetting timer when let go, count it back down
If anybody has an idea of how i could achieve this, please let me know!
local mouse = plr:GetMouse()
local timeHolding = 0
local function M1Down()
timeHolding = tick()
end
local function M1Up()
local realTime = (tick() - timeHolding)
print(realTime)
timeHolding = 0
end
mouse.Button1Down:Connect(M1Down)
mouse.Button1Up:Connect(M1Up)
this is basically the same thing as what @Innatoth suggested but unlike his suggestion were not doing a while loop each time the player is holding down his mouse.
also I know this is already solved just wanted to post this
I don’t know exactly what you mean, but in my code all I’m doing is setting TimeHolding back to 0.
As far as I know it’s impossible to make a tick count backwards, so if that’s what your trying to do then @Innatoth’s code would be the better and only option.
their might some weird math calculation you can do, but I’m not that smart
ah okay, how i wanted it is that if you let go before the timer hits x then the hammer would go back and the timer would to like tween back or whatever
edit:
maybe i could increase a number value and then tween it back when the mouse goes up?