Hello dear Facepunch-Forum,
I’m not programming anything in LUA too much, but now I wanted to try something. I wanted to make it so that if the player dies the screen fades to black. Simple, right? Yea, but the problem is that the alpha (that changes with the help of a timer) doesn’t want to apply to the box I draw over the whole screen. So can you help me please? That’s my code so far:
local playerdead = false; local alpha = 0; timer.Create("timer1",0.1,0,function() if playerdead == true then //RunConsoleCommand("say", "Alpha = "..alpha) --Used this to test if the alpha even changes, and yes: It does. if alpha > -1 then alpha = alpha+2 end end if alpha > 255 then timer.Destroy("timer1") end end); function fade1() draw.RoundedBoxEx(1,0,0,ScrW(),ScrH(),Color(0,0,0,alpha)) --That's the line that causes trouble end hook.Add("PlayerDeath","Check if player is dead", function() playerdead = true end) hook.Add("HUDPaint","Fade",fade1)
If I change the alpha to a number instead of alpha it works, but that’s not the point because it doesn’t change then. I hope you can help me.