Need help with finding an error

Could you guys help me out with finding what’s causing the error?

My code


function SWEP:PrimaryAttack()

self.Weapon:SetNextPrimaryFire(CurTime()+1.5)
self.Weapon:SendWeaponAnim( ACT_VM_PRIMARYATTACK )

local pos = self.Owner:GetShootPos()		
local ang = self.Owner:GetAimVector()
local tracedata = {}
tracedata.start = pos
tracedata.endpos = pos+(ang*100000)
tracedata.filter = self.Owner
local trace = util.TraceLine(tracedata)
local	target = trace.Entity
target:Ignite(30,10)
target:EmitSound("ambient/fire/ignite.wav", 100, 100)

The Error


[ERROR] addons/amaterasu/lua/weapons/weapon_amaterasu/shared.lua:42: attempt to call method 'Ignite' (a nil value)
  1. unknown - addons/amaterasu/lua/weapons/weapon_amaterasu/shared.lua:42

Ignite is used in connection with an entity, not a player.

  • Just realised it’s an entity you’re aiming for.

No…
He is using a shared hook and trying to run serverside function on clients side.

Change this:


 target:Ignite(30,10) 

to


 if SERVER then
target:Ignite(30,10)
end

It’ll also match your horrible scripting pattern/style :d

It still does that when used on an entity

The error about Ignite shows up ?
And if so, still on line 42 ?

Okay the that did the trick thanks , however a new error appeared. :c


if target:IsWorld() then


local fire = ents.Create("env_fire")
fire:SetPos( self.Owner:GetEyeTrace().HitPos )
fire:SetKeyValue("targetname", "fire")
fire:SetKeyValue("health", "10")
fire:SetKeyValue("fireattack", "0")
fire:SetKeyValue("ignitionpoint", "0")
fire:SetKeyValue("firesize", "150")
fire:SetKeyValue("StartDisabled", "0")
fire:SetKeyValue("spawnflags", 128 + 2)
fire:SetKeyValue("damagescale", "1")
fire:Spawn()
fire:SetOwner(self.Owner)
fire:Fire("StartFire","","0")
fire:EmitSound("ambient/fire/ignite.wav", 100, 100)

end



[ERROR] addons/amaterasu/lua/weapons/weapon_amaterasu/shared.lua:55: attempt to call field 'Create' (a nil value)
  1. unknown - addons/amaterasu/lua/weapons/weapon_amaterasu/shared.lua:55



You are killing me man! Now you are creating entities clientside!
Jeez, learn the difference between serverside and clientside (I am not mad lol).

change:


if target:IsWorld() then


local fire = ents.Create("env_fire")
fire:SetPos( self.Owner:GetEyeTrace().HitPos )
fire:SetKeyValue("targetname", "fire")
fire:SetKeyValue("health", "10")
fire:SetKeyValue("fireattack", "0")
fire:SetKeyValue("ignitionpoint", "0")
fire:SetKeyValue("firesize", "150")
fire:SetKeyValue("StartDisabled", "0")
fire:SetKeyValue("spawnflags", 128 + 2)
fire:SetKeyValue("damagescale", "1")
fire:Spawn()
fire:SetOwner(self.Owner)
fire:Fire("StartFire","","0")
fire:EmitSound("ambient/fire/ignite.wav", 100, 100)

end

to



if SERVER then
if target:IsWorld() then


local fire = ents.Create("env_fire")
fire:SetPos( self.Owner:GetEyeTrace().HitPos )
fire:SetKeyValue("targetname", "fire")
fire:SetKeyValue("health", "10")
fire:SetKeyValue("fireattack", "0")
fire:SetKeyValue("ignitionpoint", "0")
fire:SetKeyValue("firesize", "150")
fire:SetKeyValue("StartDisabled", "0")
fire:SetKeyValue("spawnflags", 128 + 2)
fire:SetKeyValue("damagescale", "1")
fire:Spawn()
fire:SetOwner(self.Owner)
fire:Fire("StartFire","","0")
fire:EmitSound("ambient/fire/ignite.wav", 100, 100)

end
end

Alrighty, thanks a bunch!

Just put


if CLIENT then return end

to the beginning of the function.