• attempt to index local 'ply' (a nil value)
    2 replies, posted
I'm trying to fix ULX's autopromote for gmod 13 but I keep getting this error: [ERROR] addons/autopromote/lua/ulx/modules/autopromote.lua:43: attempt to index local 'ply' (a nil value) 1. checkExcludes - addons/autopromote/lua/ulx/modules/autopromote.lua:43 2. unknown - addons/autopromote/lua/ulx/modules/autopromote.lua:100 The parts of code that is relevant to the errors: [code] local function checkExcludes( ply ) for id, eX in pairs (excludes) do if ply:IsUserGroup(eX) then --line 43 return true end end return false end function promotePlayer( ply ) if not checkExcludes( ply ) then --line 100 if groupSet( ply ) then if settings[1].msgOn then for ud, blank in pairs( player.GetAll()) do ULib.tsayColor(player.GetAll()[ud],false,settings[1].msgcol,ply:Nick().." has been promoted to '"..getPromoteName(ply.promote).."'.") end end if settings[1].effOn then effectS( ply ) WorldSound( "autopromote/promote.wav", ply:GetPos( 0, 0, 0 ), 160, 100 ) end ulx.adduser(nil, ply, ply.promote) end end if not timer.Exists("Promotion-" ..tostring(ply:SteamID())) then timer.Create("Promotion-" ..tostring(ply:SteamID()), 10, 0, promotePlayer, ply) end end local function timerStart( ply ) timer.Create("Promotion-" ..tostring(ply:SteamID()), 10, 0, promotePlayer, ply) end hook.Add( "PlayerInitialSpawn", "timerstarting", timerStart ) [/code] Anyone knows why? My guess is that ply isn't passed in the timer.
timer.Create( "Promotion-"..tostring(ply:SteamID()), 10, 0, function() if not (ply and IsValid(ply)) then return end promotePlayer( ply ) end )
Thanks!! It worked!
Sorry, you need to Log In to post a reply to this thread.