Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to make block reset blur affect after touching again?

This script inside a block makes things go blurry when stepped on, but idk how to turn it off after stepping on again!

local part = script.Parent

local function onPartTouched(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		game.Lighting.Blur.Size = 56
	end
end

part.Touched:Connect(onPartTouched)

local function onPartTouchedagain(otherPart)
	local partParent = otherPart.Parent
	local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
	if humanoid then
		game.Lighting.Blur.Size = 0
	end
end

part.Touchedagain:Connect(onPartTouchedagain)

(yes i purposuely made the second part super bad to get u to fix lol)

2 answers

✓ Accepted answer

it will detect when it is blurred then if it is it will make it unblur

local part = script.Parent

part.Touched:Connect(function(hit)
local partParent = hit.Parent
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if humanoid then

        if game.Lighting.Blur.Size = 56

      game.Lighting.Blur.Size = 0

       else

        game.Lighting.Blur.Size = 56
    end
end)

3 comments

0

Yay it work! also u forgot to add then after line 8 and another end but i got that in! (also u need extra = for line 8 too)

0

sorry

0

nah it fine, just giving extra script knowlege lol

But you should probably add debounce since touched can register many times in seconds

local part = script.Parent
local isFirstTime = true
local function onPartTouched(otherPart)
    local partParent = otherPart.Parent
    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
    if humanoid then
		if isFirstTime then
			game.Lighting.Blur.Size = 56
			isFirstTime = false
		else
			game.Lighting.Blur.Size = 0
		end
    end
end

part.Touched:Connect(onPartTouched)

2 comments

0

for some reason the formatting got messed up

0

idk how to do debounce

This discussion is preserved as it was. New answers, comments, and votes are closed.