• attempt to call global 'LocalPlayer' (a nil value)
    9 replies, posted
My code doesn't work cus attempt to call global 'LocalPlayer' (a nil value)... But if i will use if CLIENT then my util.SpriteTrail will not work. local function gtrail()         if SERVER then         if LocalPlayer():Team() == TEAM_GCITIZEN then             local colTrail = Color(237, 59, 59)             local trailline             if LocalPlayer():Health() == 100 then                 return true             else                   LocalPlayer().trailline = util.SpriteTrail(pPlayer, 0, colTrail, false, 100, 0, 1, 0.02, "trails/plasma.vmt")             end         else             print("job")         end     end     end hook.Add( "EntityTakeDamage", "checkevtime", gtrail ) https://files.facepunch.com/forum/upload/114477/751789e2-0e87-47cd-ab9b-36ad625fbd3a/изображение.png
Didn't we already fix this? local function gtrail() if SERVER then for k,ply in pairs(player.GetAll()) do if ply:Team() == TEAM_GCITIZEN then local colTrail = Color(237, 59, 59) local trailline if ply:Health() == 100 then ply.trailline = nil -- Remove if it exists return true else if !IsValid(ply.trailline) then -- to prevent making one every frame ply.trailline = util.SpriteTrail(ply, 0, colTrail, false, 100, 0, 1, 0.02, "trails/plasma.vmt") end end else print("job") end end end end hook.Add( "Think", "checkevtime", gtrail ) local function spawni(ply) -- Optimized for you if SERVER then return end if ply:Team() == "TEAM_GCITIZEN" then if IsValid(ply.trailline) then if IsEntity(ply.trailline) then SafeRemoveEntity(ply.trailline) end ply.trailline = nil -- Actually set it to nil end end end hook.Add( "PlayerSpawn", "some_unique_name", spawni ) hook.Add( "PlayerDeath", "gtraildelete", spawni ) -- Do we even need to do this? Better safe than sorry I guess.
It works but when i heal i still see the trail.
https://youtu.be/YmmfCsxKJUA
Can you stop creating threads for the same issue? Teams aren't strings.
Ops =)))) Lol. Haha. Sorry. And the last bug! (I think) iF I HEAL I STILL SEE MY FUCKING TRAIL. I ALREADY HATE THIS WORD... TRAAAAAAAAIL
isnt this like the third thread you made about this trail?
yeah....
Please keep it to one and bump when appropriate. Anywho, A mistake on my part In the if HEALTH === 100 then Before ply.trailline = nil SafeRemoveEntity(ply.trailline)
Thank you so much! You really helped! Thank you for your patience!
Sorry, you need to Log In to post a reply to this thread.