So right now i’m trying to make it so that when you click your primary attack button, your stamina number is subrtracted by 10. Then if your stamina number is set to 0, you get a notification that says you have lost all your stamina, and to try and rest. If anyone knows how to force the player from attacking until they have more than or equal to 1 stamina, please help with that as well. My main problem though is just seeing what I need to use to detect when they use their primary attack.
local Stamina = 100 for k,v in pairs(player.GetAll()) do if(v:KeyDown(IN_ATTACK)) then Stamina = Stamina - 10 end if Stamina <= 0 then DarkRP.Notify("You have ran out of Stamina, please rest.") local function StaminaCountUp() Stamina = Stamina + 10 end timer.create("stamniagoup",2,0,StaminaCountUp) Darkrp.Notify("Your stamina is regaining") end if Stamina == 100 then timer.Remove("staminagoup") end end hook.Add("KeyPress","StaminaControl",StaminaControl)
One thing I would like to note is that I do know that pairs is more for moving, but I have already tried Ply:KeyPressed(IN_ATTACK), but it didn’t really work.