• ERROR: HudPaint prop_door_rotating
    1 replies, posted
Okay, so I wrote this sloppy code that paints text on your screen when looking at a door. Code works just I keep getting an error when I noclip outside the map. if SERVER then return end hook.Add( "PostDrawTranslucentRenderables", "sh_door_drawdisplay", function() if LocalPlayer():Alive() then   if ( LocalPlayer():GetEyeTrace().Entity:GetClass() == "prop_door_rotating" ) then if ( LocalPlayer():GetPos():Distance( LocalPlayer():GetEyeTrace().Entity:GetPos() ) <= 100 ) then hook.Add( "HUDPaint", "Notify_Door", function() draw.DrawText( "Press ' E ' to open", "GModNotify", ScrW() / 2, ScrH() / 2 * 0.7, Color( 6, 150, 73, 255 ), TEXT_ALIGN_CENTER ) timer.Simple( 0.1, function() hook.Remove( "HUDPaint", "Notify_Door" ) end) end ) else return end end end end) Prints "Press '' E ' to open" on door when you're looking at it. https://files.facepunch.com/forum/upload/293518/61113a6a-2072-4d4a-936a-38ff9a38d227/cfa49a4e2699a2734e948b6f13b09c8b.jpg Here's the error. ERROR Error in hook PostDrawTranslucentRenderables: lua/autorun/door.lua:19: Tried to use a NULL entity! stack traceback: [C]: in function 'GetClass' lua/autorun/door.lua:19: in function 'fn' addons/ulib/lua/ulib/shared/hook.lua:110: in function <addons/ulib/lua/ulib/shared/hook.lua:93> [C]: in function '‌‎​‬‪‭' [ERROR]    1. unknown - [C]:-1
Check IsValid or not NULL as well
Sorry, you need to Log In to post a reply to this thread.