Hey, i’m planning on making a landmine SENT which activates when someone gets within a range of 21 yards/20 meters. What command can i use to make the SENT activate when someone gets in range?
Thanks, but how do i make it trigger like that? I.E let’s say it explodes if someone enters sphere?
This should help.
Sorry, that’s not what i’m looking for. I’m looking for some way to make the mine explode when someone gets near it.
He just told you it would help, which means it does exactly what you’re looking for. Just open it and see how overv did it, a working example is the best explanation you can get.
In a Think (or similar) hook of the entity, use ents.FindInSphere to get all the entities in a specific range. Filter out all but players (or, if you want prop activation or something, filter out all but players and prop_physics). If there’s any players (or props) in that filtered table, then that means there’s something inside the range of the ents.FindInSphere that’s a player. Which means you can explode it from there.
Which means :
local radius = 32 function ENT:Think() for k,v in pairs(ents.FindInSphere(self:GetPos(),radius)) do if v:IsPlayer() then self:Explode() end end end function ENT:Explode() --Explosion code end
Thanks alot guys, i hope this’ll work.