Hey guys, I’m currently attempting to make a quick reload system within my gun framework. Basically, in a tense situation you can reload quickly by tapping “R” in under 0.4 seconds, yet if you’re in a calm-type situation you can reload normally by pressing the “R” keycode.
I’ve so far managed to add the quick reload feature but am confused on adding the secondary part which will see if it’s either double tapping or tapping a singular time.
Here’s my code:
local LastTick = tick();
local Debounce = false;
local Turning = false;
local MaxDoubleDuration = 0.2;
local DebounceDuration = 0.5;
{
Index = "Reload";
KeyCode = "R";
UserInputType = nil;
Execute = function(Toggle)
if Toggle then
if not Debounce then
if tick() - LastTick <= MaxDoubleDuration then
Debounce = true;
Turning = true;
Weapon:reload(Toggle, Turning);
end
LastTick = tick();
end
else
if Turning then
Turning = false;
wait(DebounceDuration);
Debounce = false;
end
end
end,
};
most code is not included because it is irrevelant so yes when i click “R” it does function