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

Loop not working ?

Asked by
Bulvyte 388 Moderation Voter
8 years ago
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 ?

0
Just make the transparency equal to i/100. User#11440 120 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago
debounce = false
Vispart = script.Parent.Parent.BasePlate--to change if you want
vison = false
script.Parent.Touched:connect(function(touch)
if debounce == false then   
    if vison == false then
        debounce = true
        vison = true        
        for i = 1,100 do
            print(i)
            Vispart.Transparency = Vispart.Transparency + 0.01
            wait(0.01)
        end
    elseif vison == true then
        debounce = true
        vison = false
        for i = 1,100 do
            print(i)
            Vispart.Transparency = Vispart.Transparency - 0.01
            wait(0.01)
        end
    end
        wait(1)
        debounce = false
        print("Ready to fire again!")
    end
end)

You basically had the logic of your function set up wrong.

0
My mind is confused af i dont understand whats this vision and.... please explain Bulvyte 388 — 8y
Ad

Answer this question