Timer not seeming to work

I am trying to make a propane tank where when you press e on it, it turns on fire for 5 seconds. Then it explodes and deletes the entity. For some reason, it explodes right off the bat. No flames. I want the timer to wait. Thanks.

Init.lua:
[lua]
AddCSLuaFile( “cl_init.lua” ) – Make sure clientside
AddCSLuaFile( “shared.lua” ) – and shared scripts are sent.

include(‘shared.lua’)

function ENT:Initialize()

self.Entity:SetModel( "models/props_junk/PropaneCanister001a.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS )         -- Toolbox

    local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
	phys:Wake()
end

local timeignited=5

end

function ENT:Use( activator, caller )

if( self.Entity:IsOnFire() )then return end

	self.Entity:Ignite( timeignited, 0 )
	timer.Simple(timeignited, self.Explode( 500 ), self)

end

function ENT:Think()
– We don’t need to think, we are just a prop after all!
end

function ENT:Explode( magnitude )

local explosion = ents.Create( "env_explosion" )
	explosion:SetPos( self.Entity:GetPos() )
	explosion:SetKeyValue( "iMagnitude" , magnitude )
	explosion:SetPhysicsAttacker(owner)
	explosion:SetOwner(owner)
	explosion:Spawn()
	explosion:Fire("explode","",0)
	explosion:Fire("kill","",0 )
	
	self.Entity:Remove()

end
[/lua]

timeignited is a local variable, you need to put it where you want to call it, here you need to put it in ENT:Use()

i still get a error that self is a number at line 38…

try to put just self:GetPos()
or put thing like Pos = Self:GetPos() in ENT:Think and replace explosion:SetPos( Self.Entity:GtPos() ) by explosion:SetPos( Pos )

now i get a error saying that SetKeyValue needs a string, but i put it to a string and it still does the problem from 1st post.

[lua] explosion:SetKeyValue( “iMagnitude” , “magnitude” ) [/lua]

No

[lua]explosion:SetKeyValue(“iMagnitude”, “500”) – Change this number[/lua]

I was pointing out the string.

What you posted will just confuse things, you need to be more clear.

so, am i able to do magnitude = “500” or do i have to just use SetKeyValue(“iMagnitude”, “500”)?

Use what MakeR said.

You can do that.

[lua]local magnitude = “500”
explosion:SetKeyValue(“iMagnitude”, magnitude)[/lua]

So far, i have this:
[lua]
AddCSLuaFile( “cl_init.lua” ) – Make sure clientside
AddCSLuaFile( “shared.lua” ) – and shared scripts are sent.

include(‘shared.lua’)

function ENT:Initialize()

self.Entity:SetModel( "models/props_junk/PropaneCanister001a.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS )         -- Toolbox

    local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
	phys:Wake()
end

end

function ENT:Use( activator, caller )

local timeignited=5

if( self.Entity:IsOnFire() )then return end

	self.Entity:Ignite( timeignited, 0 )
	timer.Simple(timeignited, self.Explode(), self)

end

function ENT:Think()
Propanepos = self:GetPos()
end

function ENT:Explode()

local explosion = ents.Create( "env_explosion" )
	explosion:SetPos( Propanepos )
	explosion:SetKeyValue( "iMagnitude" , "500" )
	explosion:SetPhysicsAttacker(owner)
	explosion:SetOwner(owner)
	explosion:Spawn()
	explosion:Fire("explode","",0)
	explosion:Fire("kill","",0 )
	
	self.Entity:Remove()

end
[/lua]

So, the timer still seems not to work, which means that the propane tank explodes off the bat still. Also, now the entity will not remove with a error saying Entity is a nil value at line 46. I tried to remove it and it says that Remove is a nil value.

Edit:
Any fix for this?

i think its time for a bump, any answers? i am stumped…

[lua]AddCSLuaFile( “cl_init.lua” ) – Make sure clientside
AddCSLuaFile( “shared.lua” ) – and shared scripts are sent.

include(‘shared.lua’)

function ENT:Initialize()

self.Entity:SetModel( "models/props_junk/PropaneCanister001a.mdl" )
self.Entity:PhysicsInit( SOLID_VPHYSICS )      -- Make us work with physics,
self.Entity:SetMoveType( MOVETYPE_VPHYSICS )   -- after all, gmod is a physics
self.Entity:SetSolid( SOLID_VPHYSICS )         -- Toolbox

    local phys = self.Entity:GetPhysicsObject()
if (phys:IsValid()) then
	phys:Wake()
end

end

function ENT:Use( activator, caller )

local timeignited=5

if( self.Entity:IsOnFire() )then return end

	self.Entity:Ignite( timeignited, 0 )
	timer.Simple(timeignited, self.Explode, self)

end

function ENT:Think()
end

function ENT:Explode()

local explosion = ents.Create( "env_explosion" )
	explosion:SetPos( self:GetPos() )
	explosion:SetKeyValue( "iMagnitude" , "500" )
	explosion:SetPhysicsAttacker(owner)
	explosion:SetOwner(owner)
	explosion:Spawn()
	explosion:Fire("explode","",0)
	explosion:Fire("kill","",0 )
	
	self.Entity:Remove()

end
[/lua]