Help :3



usermessage.Hook("LoadLevelInformation",function(um)
	local user = LocalPlayer()
	
	local datasection = um:ReadString()
	local teamtable = um:ReadString()
	local classnum = um:ReadFloat()
	local value = um:ReadFloat()
	
	if not user[datasection] then user[datasection] = {} end
	if not user[datasection][teamtable] then user[datasection][teamtable] = {} end
	user[datasection][teamtable][classnum] = value
end)


This prints a lua error saying the field ‘?’ is nil. The ? is actualyl there in the error btw. I have no idea what’s causing this. Any insight?

LocalPlayer is an entity, not a table. however that being said you can run LocalPlayer()[“GetName”] and it will work.

try debugging it with print. as in something like:
[lua]
usermessage.Hook(“LoadLevelInformation”,function(um)
local user = LocalPlayer()

local datasection = um:ReadString()
local teamtable = um:ReadString()
local classnum = um:ReadFloat()
local value = um:ReadFloat()

print(dataselection, teamtable, classnum, value);

if (!user[dataselection]) then
	print ( Format("Player does not have method: %s", dataselection) );
	return; // this will stop the code here and prevent it from erroring!
	
end

if not user[datasection] then user[datasection] = {} end
if not user[datasection][teamtable] then user[datasection][teamtable] = {} end
user[datasection][teamtable][classnum] = value

end)
[/lua]

[editline]23rd July 2012[/editline]

oh also for lua code use [lua][/lua] tags :slight_smile: