Particle system based explosion, :1: '=' expected near '/'

So, take a look and fix it if possible, and please tell me what was wrong.
[lua]
explode = ents.FindByClass(“env_explosion”)
if(explode:isValid == 1) then
Part = ents.Create(“info_particle_system”)
Pos = explode:LocalToWorld( explode:OBBCenter( ) )
part.ParticleSystem:SetPos(Pos)
explode:remove
part.ParticleSystem:SetKeyValue( “effect_name”, “grenade_explosion_01”)
part.ParticleSystem:SetKeyValue( “start_active”, 1)
part.ParticleSystem:Spawn()
part.ParticleSystem:Activate()
end[/lua]

On your first if statement, isValid isn’t properly capitalized, it’s “IsValid”.

:IsValid is also a function call not a property.

[lua]

if( explode:IsValid() ) then

end
[/lua]

OK, thanks :downs:

Line 06 should be :

[lua]explode:Remove()[/lua]

:7: function arguments expected near ‘part’
The new error!

Kialtia’s post above is the answer.

[lua] explode = ents.FindByClass(“env_explosion”)
if( explode:IsValid() ) then
Part = ents.Create(“info_particle_system”)
Pos = explode:LocalToWorld( explode:OBBCenter( ) )
part:SetPos(Pos)
explode:Remove()
part:SetKeyValue( “effect_name”, “grenade_explosion_01”)
part:SetKeyValue( “start_active”, 1)
part:Spawn()
part:Activate()
end

[/lua]

Lua is case sensitive, Part and part are two different things.

IsValid is a nil value now, and It will not do anything.
Also, sorry, I’m just starting to learn Lua.

[editline]12:21AM[/editline]

I did not notice the capital P in the first part.
I will try that now

Oh and IsValid doesn’t work on tables.

[lua]
local explode = ents.FindByClass(“env_explosion”) // returns a table with all entities of specified class.

for k,v in pairs( explode ) do // Loop through each element of the table
	
	if( v:IsValid() ) then // make sure that every env_explosion entity in the explode table is valid.
		
		local Pos = v:LocalToWorld( v:OBBCenter( ) )
		
		local part = ents.Create("info_particle_system")
		part:SetPos(Pos)
		part:SetKeyValue( "effect_name", "grenade_explosion_01")
		part:SetKeyValue( "start_active", 1)
		part:Spawn()
		part:Activate()
		
		v:Remove()
		
	end
end

[/lua]

Still not working

[editline]12:28AM[/editline]

Wait, did not see hoffas code

It’s much easier to do particles as ParticleEffect()

No errors, but still not doing anything.

[editline]12:39AM[/editline]
[lua]
local explode = ents.FindByClass(“env_explosion”) // returns a table with all entities of specified class.

for k,v in pairs( explode ) do // Loop through each element of the table
    
    if( v:IsValid() ) then // Make sure that every env_explosion entity in the explode table is valid.
        
        local Pos = v:LocalToWorld( v:OBBCenter( ) )
        ParticleEffect("grenade_explosion_01",Pos, Angle(0,0,0), nil)
    end
end

[/lua]

Chuck a print in there somewhere to see if it’s actually picking up any entities.

Good idea

[editline]07:44AM[/editline]

Nope, still not working, and just to be sure, you put print like this: print(“String Here”)
Right?

[editline]07:45AM[/editline]

Nope meaning: It is not picking up anything.

Are there any explosions in the map?

No, the point is to find the explosion entities and replace them with particle effects, to remove the plain old boring HL2 explosion

Is it not possible just to completely override the default explosion with the particle effects instead of having to find and replace the default?