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

I made a blink script. It not's really working. Help?

Asked by 6 years ago

So i've made my own blink script (Since one is copied) and i don't get what's wrong this?

local blink = 5

local zero = script.Parent.M
local one = script.Parent.N
local two = script.Parent.X
local three = script.Parent.Y
local four = script.Parent.Z

while wait() do
    wait(5)
    blink = blink-1
end

while wait() do
wait()
    if blink == 5 then
    four.Visible = true
    three.Visible = true
    two.Visible = true
    one.Visible = true
    zero.Visible = true
end
if blink == 4 then
    four.Visible = false
    three.Visible = true
    two.Visible = true
    one.Visible = true
    zero.Visible = true
end
if blink == 3 then
    four.Visible = false
    three.Visible = false
    two.Visible = true
    one.Visible = true
    zero.Visible = true
end
if blink == 2 then
    four.Visible = false
    three.Visible = false
    two.Visible = false
    one.Visible = true
    zero.Visible = true
end
if blink == 1 then
    four.Visible = false
    three.Visible = false
    two.Visible = false
    one.Visible = false
    zero.Visible = true
end
if blink == 0 then
    four.Visible = false
    three.Visible = false
    two.Visible = false
    one.Visible = false
    zero.Visible = false
    script.Parent.Parent.Fill.Visible = true
    wait(1.5)
    script.Parent.Parent.Fill.Visible = false
    blink = 5
end
end
0
Scripts go from top to bottom. If it enters a loop do you think it exits the loop unless you tell it to? Pejorem 164 — 6y

1 answer

Log in to vote
0
Answered by
Pejorem 164
6 years ago

I can't be bothered to in depth with what I've done here but hopefully you've got the effort to study the below code.

local blinkInfo = {
    {true, true, true, true, true},
    {false, true, true, true, true},
    {false, false, true, true, true},
    {false, false, false, true, true},
    {false, false, false, false, true},
    {false, false, false, false, false}
}

local scriptParent = script.Parent
local zero = scriptParent.M
local one = scriptParent.N
local two = scriptParent.X
local three = scriptParent.Y
local four = scriptParent.Z

while true do
    for i = 1, 5 do
        four.Visible = blinkInfo[i][1]
        three.Visible = blinkInfo[i][2]
        two.Visible = blinkInfo[i][3]
        one.Visible = blinkInfo[i][4]
        zero.Visible = blinkInfo[i][5]
        if i == 5 then
            scriptParent.Parent.Fill.Visible = true
            wait(1.5)
            script.Parent.Parent.Fill.Visible = false
        else
            wait()
        end
    end
end
0
Basically. What i'm guessing is that. It's just numbers that equal to ways the blink meter is showing. is like 1 is all visible. 6 is all the meters gone and it just basically going back on it self repeating the same thing slay_unknown -3 — 6y
0
Yeah I've basically just written what you had more efficiently. Add me on discord if you've got questions Instance.new("Life", Noob)#3135 Pejorem 164 — 6y
0
Your main issue with the original code was that you never exited the first while loop lol. So you could either solve that through the use of coroutines... or have one while loop instead of two. My response just cleans it up a bit so it's more easy to understand the actual processing. Although the multidimensional table is nothing less than more confusing and easy to make mistakes with lol... Pejorem 164 — 6y
0
So if I could see your studio file I'd probably come up with a better solution. But if you focus on my use of a for loop to sequence the changes from A to B hopefully you can think of something better yourself Pejorem 164 — 6y
Ad

Answer this question