debounce = false function onTouch() if debounce == false then debounce = true for i = 1,100 do print(i) script.Parent.Parent.BasePlate.Transparency = script.Parent.Parent.BasePlate.Transparency + 0.01 wait(0.01) end wait(5) debounce = false else if script.Parent.Parent.BasePlate.Transparency == 1 then for i = 1,100 do print(i) script.Parent.Parent.BasePlate.Transparency = script.Parent.Parent.BasePlate.Transparency - 0.01 --here wait(0.01) end end end end script.Parent.Touched:connect(onTouch)
So simply this should make invisible brick once u touch a trigger, and once u touch it again make it visible so u can keep repeating making it visible and invisible, but it doesn't work all it does it make it invisible and the last part doesn't work. Help ?
debounce = false function onTouch() if debounce == false then for i = 1,100 do print(i) script.Parent.Parent.BasePlate.Transparency = script.Parent.Parent.BasePlate.Transparency + 0.01 wait(0.01) debounce = true end wait(5) elseif debounce == true then for i = 1,100 do print(i) script.Parent.Parent.BasePlate.Transparency = script.Parent.Parent.BasePlate.Transparency - 0.01 --here wait(0.01) debounce = false end end end end script.Parent.Touched:connect(onTouch)
well your debounce variable is kinda useless, it should really be used in both if statements also it would look less confusing if you put script.Parent.Parent.BasePlate.Transparency into a variable