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 3 years ago
Edited 3 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!

01local part = script.Parent
02 
03local function onPartTouched(otherPart)
04    local partParent = otherPart.Parent
05    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
06    if humanoid then
07        game.Lighting.Blur.Size = 56
08    end
09end
10 
11part.Touched:Connect(onPartTouched)
12 
13local function onPartTouchedagain(otherPart)
14    local partParent = otherPart.Parent
15    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
View all 21 lines...

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

2 answers

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

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

01local part = script.Parent
02 
03part.Touched:Connect(function(hit)
04local partParent = hit.Parent
05    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
06    if humanoid then
07 
08        if game.Lighting.Blur.Size = 56
09 
10      game.Lighting.Blur.Size = 0
11 
12       else
13 
14        game.Lighting.Blur.Size = 56
15    end
16end)
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 — 3y
0
sorry Trampyling 43 — 3y
0
nah it fine, just giving extra script knowlege lol Jakob_Cashy 79 — 3y
Ad
Log in to vote
0
Answered by
tomekcz 174
3 years ago
Edited 3 years ago

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

01local part = script.Parent
02local isFirstTime = true
03local function onPartTouched(otherPart)
04    local partParent = otherPart.Parent
05    local humanoid = partParent:FindFirstChildWhichIsA("Humanoid")
06    if humanoid then
07        if isFirstTime then
08            game.Lighting.Blur.Size = 56
09            isFirstTime = false
10        else
11            game.Lighting.Blur.Size = 0
12        end
13    end
14end
15 
16part.Touched:Connect(onPartTouched)
0
for some reason the formatting got messed up tomekcz 174 — 3y
0
idk how to do debounce Jakob_Cashy 79 — 3y

Answer this question