Could someone take a look at this, and tell me what's wrong?

Title says it all.

Here’s my code:



function WhenSpawningz(ply)
if file.Exists( "epixrp/savedplayerarmor" .. ply:UniqueID() .. ".txt", "DATA")  then
readfromfile = file.Read( "epixrp/savedplayerarmor" .. ply:UniqueID() .. ".txt")
lines = string.Explode(";", readfromfile)    
	for i, line in ipairs(lines) do
	
	data = string.Explode(";", line)
 
	model = data[1]
	speed = data[2]
	health = data[3]
 

end
	 
	
   
    ply:ChatPrint("Your armor with " .. data[3] .. " health has been loaded")
    else return false

end
end
 
hook.Add( "PlayerLoadout", "PlayerSpawnMessagez", WhenSpawningz )


I’m getting this error:



[ERROR] gamemodes/darkrp/entities/entities/npc_armor/init.lua:76: attempt to concatenate a nil value


I’m trying to get it to only print what’s on line 3 in the txt document, but it does not seem to work. Could someone help?

I’m assuming data[3] does not exist, print the table check its contents.

It’s printing out like this:



Data: 	=	{
"models/player/slow/tau_commander/slow_tau_commander.mdl --model
663 --walkspeed
663 --runspeed
7836 --health
2295 --armor
",
}



How would i go about only printing line 3 out?

Looks like your file is just a single entry in the table.
Take a look at JSONToTable and TableToJSON, it’s much more convenient for storing and retrieving data in text files.