Help with HP code [DELETE THREAD]

I made some lua code for an HP system in SRB2, but it ended up giving me this error when I stomped on badniks:
WARNING: /Users/REDACTED/srb2/UndertaleHP.pk3|Lua/HP.lua:4: attempt to index local 'player' (a nil value)
stack traceback:
/Users/REDACTED/srb2/UndertaleHP.pk3|Lua/HP.lua:4: in function </Users/REDACTED/srb2/UndertaleHP.pk3|Lua/HP.lua:2>
HP code snippet:
//basic HP system.
addHook("MobjDamage", function(mo, inf, src, dmg, dmgtype)
    local player = mo and mo.valid and mo.player
    player.hp = $-4
end)
Is there a way to fix this?

UPDATE: I fixed it, please delete this thread.
 
Last edited:

Who is viewing this thread (Total: 1, Members: 0, Guests: 1)

Back
Top