Hello I keep getting the attempt to index a nil value error, but I put a , 0. I am not sure why this is happening. Below is the error and the line giving me the issue.
Line:
[CODE] if pl:getChar():getData("Skill_HP", 0) >= 1 then [/CODE]
Error:
[CODE]
[ERROR] addons/skillsystem/lua/autorun/server/sv_experience.lua:32: attempt to index a nil value
1. fn - addons/skillsystem/lua/autorun/server/sv_experience.lua:32
2. Run - addons/ulib-master/lua/ulib/shared/hook.lua:110
3. unknown - gamemodes/nutscript/gamemode/core/hooks/sv_hooks.lua:268
[/CODE]
[QUOTE=pogh10;52312862]Hello I keep getting the attempt to index a nil value error, but I put a , 0. I am not sure why this is happening. Below is the error and the line giving me the issue.
Line:
[CODE] if pl:getChar():getData("Skill_HP", 0) >= 1 then [/CODE]
Error:
[CODE]
[ERROR] addons/skillsystem/lua/autorun/server/sv_experience.lua:32: attempt to index a nil value
1. fn - addons/skillsystem/lua/autorun/server/sv_experience.lua:32
2. Run - addons/ulib-master/lua/ulib/shared/hook.lua:110
3. unknown - gamemodes/nutscript/gamemode/core/hooks/sv_hooks.lua:268
[/CODE][/QUOTE]
I can't find the getData method on the wiki... Did you make it yourself? And you should be using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/sub]string.sub[/url], because getChar() is deprecated.
The return value from getChar is nil.
[QUOTE=MrRalgoman;52312890]I can't find the getData method on the wiki... Did you make it yourself? And you should be using [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/string/sub]string.sub[/url], because getChar() is deprecated.[/QUOTE]
It's not the same `getChar`, Lua is case sensitive
Sorry, you need to Log In to post a reply to this thread.