DrawMotionBlur Issue

Trying to make a motion blur disappear after a certain amount of time.


local shouldDrawBlur = false
local function beerDrink()
	function GAMEMODE:RenderScreenspaceEffects()
		shouldDrawBlur = true
		timer.Simple(5,function() shouldDrawBlur = false end)
		if shouldDrawBlur == true then
			DrawMotionBlur( 0.04, 0.7, 0.05 )
		elseif shouldDrawBlur == false then
			DrawMotionBlur(0,0,0)
		end
	end
end

It also doesn’t seem to be redefining shouldDrawBlur as false for some reason, not sure if anyone can help me with this. Would be much appreciated.

  1. Never have a function inside another function. (Until you’re more advanced with lua)

GAMEMODE is only valid after the gamemode have launched. Doing a gamemodes launch its GM. (You can get the current one with this function:

gmod.GetGamemode)
3) Use the hook system instead. I know you followed the wiki, but its wrong. You shouldn’t override the base function and hooks are way easier.
You can see an example of RenderScreenspaceEffects on the old wiki: https://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index6d80.html

Protip; including this line at the top in the hook function, will allow it to be toggleable:


if not shouldDrawBlur then return end

You are setting shouldDrawBlur to true every frame, thats why it is never false. And what Nak said

Thanks a bunch!