• attempt to index global 'ply' (Star Wars Light saber error)
    7 replies, posted
[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. [CODE]local dmgtrain = DamageInfo() local training = { [TEAM_SITH] = true, } if training[ply:Team()] then dmgtrain:SetDamages( 1 ) end[/CODE]
Can you post some more context? [editline]7th December 2016[/editline] Maybe the whole function?
[QUOTE=Gordon Johnso;51494738][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. [CODE]local dmgtrain = DamageInfo() local training = { [TEAM_SITH] = true, } if training[ply:Team()] then dmgtrain:SetDamages( 1 ) end[/CODE][/QUOTE] 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.
[QUOTE=FirstOrder;51495173]You have to define player somewhere. Guessing by your code it should be defined as: [CODE]local ply = LocalPlayer()[/CODE][/QUOTE] Doubt it, should be server side. [QUOTE=Gordon Johnso;51495067]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.[/QUOTE] 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 [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/ScalePlayerDamage]GM:ScalePlayerDamage[/url]
[QUOTE=smithy285;51495326]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 [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/GM/ScalePlayerDamage]GM:ScalePlayerDamage[/url][/QUOTE] 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
[QUOTE=Gordon Johnso;51499627]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[/QUOTE] Why don't you add me on Steam, my link is below my avatar, perhaps I can help you better that way
Sorry, you need to Log In to post a reply to this thread.