So while working on an FPS system, I’ve run across the problem of making auto-reload cancel when you shoot. Currently when you click it does this:
(pseudocode + unneeded fluff removed)
function MouseDown()
--shoot
--I want this function to cancel reloading
end
function MouseUp()
--cancel shooting
if not reloading and not shooting then
reloading = true
wait(ReloadTime)
--Now I know some people will say to check if you're shooting here,
--but that will only check if the mouse is down after the yield
--meaning that shooting mid-reload will still allow you to finish reloading
Ammo = MaxAmmo
reloading = false
end
end
I’m stumped and tired. If you need further clarification please ask. I’ve spent around 5 hours on this one simple concept.
Things I've Tried
- Disconnecting the function (oh wait i cant use the function again after Disconnecting)
- That stuff I commented
- using a function inside the if statement to return
- making a hacky function that would cancel when another function is called (see 1)
- making a loop that would only run once every time the function is called
- a million other things
- asking it nicely
ask questions if needed