Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make block reset blur affect after touching again?

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
1
Answered by 2 years ago
Edited 2 years ago

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)

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) Jakob_Cashy 79 — 2y
0
sorry Trampyling 43 — 2y
0
nah it fine, just giving extra script knowlege lol Jakob_Cashy 79 — 2y
Ad
Log in to vote
0
Answered by
tomekcz 174
2 years ago
Edited 2 years ago

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)
0
for some reason the formatting got messed up tomekcz 174 — 2y
0
idk how to do debounce Jakob_Cashy 79 — 2y

Answer this question