Hello, I have recently made my own swep with the intention of it being picked up by users as they play and being used at will to give them a quick health buff. I dont want this health buff to be permament and I want it to disapear after a short while allthough I am having trouble getting the timer to work properly.
Here is the code for the timer that I have put in the “innit.lua” file
timer.Create("HPtimer", 5, 1, function() PrintMessage( HUD_PRINTTALK, "You feel the effects of the cola wear off!" ); self.Owner:SetHealth("100") self.Owner:SetMaxHealth("100") end)
Here is the code that I have put into the shared.lua file.
function SWEP:PrimaryAttack() self.Owner:SetMaxHealth("150") self.Owner:SetHealth("150") self:Remove() timer.Start("HPtimer") end
As you can see I am wanting the timer to start when the SWEP is used but this is not the case as the timer starts as soon as the server loads. Here is an error I also get in console allthough this may not be related as im kind of inexperiened…This being my first time coding anything in lua and all =S.
Thanks in advance for any help I receive! And for glancing at this thread too!