Ignite someone

I was just wondering how I can ignite a player with the left click of a swep.
Something like
[lua]
Ingite(Player)
[/lua] I would think.

ply:Ingite()

[lua]
function SWEP:PrimaryAttack()
local trace = self.Owner:GetEyeTrace()
if trace.Entity:IsValid() then
if trace.Entity:IsPlayer() then
trace.Entity:Ignite(20)
end
end
end
[/lua]

20 is the duration of the ignite in seconds.

Alright, thanks you very much :slight_smile:

[editline]07:42PM[/editline]

Would I change it to
[lua]
function SWEP:PrimaryAttack()
local trace = self.Owner:GetEyeTrace()
if trace.Entity:IsValid() then
if trace.Entity:IsNPC() then
trace.Entity:Ignite(45)
end
end
end
[/lua]
To Ingite an NPC?

Yes, It should work like that.

You could also set the distance for the fire to spread to another object.
[lua]
ent:Ignite(10,32) ā€“ ignite for 10 seconds, and ignite other objects 32 units from you.
[/lua]

Iā€™m trying to make a pistol that shoots a normal bullet, but when it hits something it ignites it.

It only spreads to breakable props.