1. This forum is ARCHIVED! Visit the new Cloud Sixteen forums, codename Eden, at https://eden.cloudsixteen.com. These forums will remain archived for a few months before being closed down, so try to encourage plugin developers to begin moving their content across to the new forums.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

ERROR for code!

Discussion in 'Discussion' started by _HappyGoLucky, Mar 15, 2014.

  1. _HappyGoLucky

    _HappyGoLucky Clockwork Customer

    I recently made this grappling hook and I really wanna fix it as soon as possible!

    Whenever I die from a drop with the crossbow equipped sometimes I crash with this error!

    [Grappling hook V2] lua/entities/trace2/cl_init.lua:66: attempt to index local 'attachment' (a nil value)
    1. unknown - lua/entities/trace2/cl_init.lua:66

    In the code line 66 (Including surronding lines!)

    local vm = Owner:GetViewModel()
    if (!vm || vm == NULL) then return end
    local attachment = vm:GetAttachment( 1 )
    StartPos = attachment.Pos (THIS IS LINE 66!)

    else

    local vm = Owner:GetActiveWeapon()
    if (!vm || vm == NULL) then return end
    local attachment = vm:GetAttachment( 1 )
    StartPos = attachment and attachment.Pos
     
  2. _HappyGoLucky

    _HappyGoLucky Clockwork Customer

    I am new to coding, that is something I really couldn't do.
     
  3. _HappyGoLucky

    _HappyGoLucky Clockwork Customer

    I nearly lost this, if someone could still help me with it?
     
  4. Viomi

    Viomi Running ArchLinux

    Your problem is the "vm:GetAttachment( 1 )". When you die with your crossbow out, I believe it returns no attachment, and therefore a nil value; Causing the crash.
     
  5. _HappyGoLucky

    _HappyGoLucky Clockwork Customer

    How do I fix it?
     

Previous Readers (Total: 0)