First Person Death addon won't work.

Hey, everyone. The first person death Addon posted on doesn’t want to work for me. I have placed the “First_Person_Death” File inside my addons. It has one subfolder: /Lua. Inside that folder is the /autorun/Fpdeath.lua file and it just doesn’t seem to work. I have tried placing the code inside my actual lua/autorun folder but with no luck. I took a look at the source and couldn’t find any errors. Maybe the update has messed it up? The source code is as follows:

if( SERVER ) then

 AddCSLuaFile( "autorun/fpdeath.lua" );


// client
if( CLIENT ) then

 local function CalcView( pl, origin, angles, fov )

     // get their ragdoll
   local ragdoll = pl:GetRagdollEntity();
   if( !ragdoll || ragdoll == NULL || !ragdoll:IsValid() ) then return; end
    // find the eyes
    local eyes = ragdoll:GetAttachment( ragdoll:LookupAttachment( "eyes" ) );
     // setup our view
     local view = {
         origin = eyes.Pos,
         angles = eyes.Ang,
		 fov = 90, 
     return view;
  hook.Add( "CalcView", "DeathView", CalcView );


Could anyone find out the problem for me? Thanks a lot Facepunch.

Are you using DeathFix?

No. Im not using death fix. I haven’t downloaded that addon. However, I HAVE heard that it messes with the first person death view addon. Any more suggestions? Thank you ralle!

I have looked inside my console to find an error and this is what I got:
autorun/fpdeath.lua= attempted to call global ‘singleplayer’ (a nil value.) Well nil means nothing, so maybe singleplayer isn’t defined? I’m a novice in lua, and I really can’t solve this one.

Well, it doesn’t say singleplayer anywhere in the code you posted:sigh:

I know. It just doesn’t make sense too me. Any suggestions? Maybe you could test out this code. Just add it into your lua/autorun file and name it fpdeath.lua. Tell me what happens. :slight_smile:

It should give the line number in the error, that way you can pinpoint the exact part of the code that is causing the error

autorun/fpdeath.lua:4: ? Maybe line 4?

Edit: I found a website that shows my error. It is number 3. I attempt to call a global ‘varname’ a nil value. In my case its singleplayer. “You tried to assign an index on an array that’s nil. (isn’t defined yet)” is the reason it says.

I have officially solved the error. A fresh re-install! :slight_smile: Thanks everyone who pitched in, especially djjkxbox! :slight_smile: