• SWEP needs to affect all entities in local radius of player
    3 replies, posted
Attampting to make my SWEP find all entities in a sphere radius around player, then push them away. this will happen when the player pushes primaryattack (mouse1). local tr = Entity( 1, 30 )FindInSphere( Vector(Entity:GetPos()), 1000 ) <--- this line is the problem if IsValid( tr.Entity ) then local phys = tr.Entity:GetPhysicsObjectNum( tr.PhysicsBone ) local pushvec = tr.Normal * 150000 local pushpos = tr.HitPos phys:SetMass( 50 ) phys:ApplyForceOffset( pushvec, pushpos ) end end )
You're damn right that line's the problem. Entity(1, 30)FindInSphere( What the hell is that even supposed to do?
This line worked previously --local tr = Entity( 1 ):GetEyeTrace() It would select what item the player was looking at So i assumed if I just changed the function at the end from GetEyeTrace() to FindInSphere(...) it would set the selected entity to any item in a sphere around the player
You have no idea how to use the FindInSphere function. It's not a function of the Entity class, it's one of the ents library. You need to do ents.FindInSphere. That's only the beginning of your problems, because you're also just calling Entity(). That returns nothing. Third of all, Entity(1) will only affect the first entity on the server, which will always be the first player connected.
Sorry, you need to Log In to post a reply to this thread.