• Need help with ModelView file in lua/autorun
    0 replies, posted
Hey guys, I've been trying to create a modelview that only works when a person is alive. I've placed this in lua/autorun [CODE] if (LocalPlayer():Alive()) or LocalPlayer():Team() ~= TEAM_SPEC then local function clhudmodel() iconmodel = vgui.Create("DModelPanel") iconmodel:SetModel( LocalPlayer():GetModel()) function iconmodel:LayoutEntity( Entity ) return end iconmodel:SetPos(22, ScrH() - 150) iconmodel:SetAnimated(true) iconmodel:SetSize(130,130) iconmodel:SetCamPos( Vector( 14, 4, 65)) iconmodel:SetLookAt( Vector( 0, 0, 66.5 ) ) timer.Create("RefreshAvatar", 1, 0, function() if LocalPlayer():GetModel() ~= iconmodel.Entity:GetModel() then iconmodel:Remove() iconmodel = vgui.Create("DModelPanel") iconmodel:SetModel( LocalPlayer():GetModel()) function iconmodel:LayoutEntity( Entity ) return end iconmodel:SetPos(22, ScrH() - 150) iconmodel:SetAnimated(true) iconmodel:SetSize(130,130) iconmodel:SetCamPos( Vector( 14, 4, 65)) iconmodel:SetLookAt( Vector( 0, 0, 66.5 ) ) end end) end hook.Add("InitPostEntity", "DrawPlayerModel", clhudmodel) end [/CODE] And I keep getting an error about how Alive is a nil value for LocalPlayer(). This is because everything hasn't initialized yet, including LocalPlayer(). How do I fix this, so that I can make the script "wait" until everything is initialized before running? Thanks for your help.
Sorry, you need to Log In to post a reply to this thread.