attempt to index global 'ply' (Star Wars Light saber error)

[ERROR] addons/star wars lightsabers/lua/weapons/weapon_lightsaber.lua:646: attempt to index global ‘ply’ (a nil value)

  1. unknown - addons/star wars lightsabers/lua/weapons/weapon_lightsaber.lua:646

Please note that I do know this is a table, I just wanted to see if it would work, but regarldess it would still give me the same error. I’ve tried ply:Team, and almost any other solution I could think of.

local dmgtrain = DamageInfo()
local training = {
	[TEAM_SITH] = true,

if training[ply:Team()] then
dmgtrain:SetDamages( 1 )

Can you post some more context?

[editline]7th December 2016[/editline]

Maybe the whole function?

Are you defining ply anywhere? Can you post the function? If there a function?

There’s no function, and that is pretty much the code that’s causing the issue. Basically, what I’m trying to do is detect what a players team/ darkRP jobs is in order to make the lightsaber inflict that ammount of damage.

You have to define ply or give it a value somewhere.

Doubt it, should be server side.

Your error very clearly says that ‘ply’ is nil. ‘SetDamage’ is part of the ‘CTakeDamageInfo’ class. As a result, you should use something that returns the ply and CTakeDamageInfo class, such as


That wouldn’t make much since though because i’m using the same type of local that was used in another part of the lightsaber script. But I tried anyways, and still didn’t get it to work. Anymore solutions would be awesome, thank you

Why don’t you add me on Steam, my link is below my avatar, perhaps I can help you better that way