I’m making a small custom SWEP for a fairly useless mini-project of mine, and this is what I have.
local tr = self.Owner:GetEyeTrace().Entity if not tr:IsValid() then return end if tr:IsPlayer() then else return end if tr:GetPos():Distance( self.Owner:GetPos() ) > self.Primary.Distance then return end if SERVER then self.Owner:EmitSound( self.Primary.Sound, 75, 160 ) tr:SetHealth( tr:Health - 5 ) --Damages Player for 5 HP end
I’m trying to make it so that when a player is within distance in eyetrace, it removes 5HP and plays a sound.
**Problem 1:**The sound works but it refuses to make the victim’s HP minus 5.
**Problem 2:**How can I go about making a small ‘nudge’ effect you see on other SWEPs, where the victim takes pain and it nudges him a little in the opposite direction?
Thanks in advance for any help/info guys, I appreciate it.