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

Why does this loop do this ?

Asked by
Bulvyte 388 Moderation Voter
8 years ago

What i want it to do is just go from 0 to 0.30 and keep repeating but they just go to -1 then back to 1 why does this happen ?

glow = script.Parent
num = 30
while true do
    for i = 1, num do
        glow.Transparency = 0+i/num/1
        wait()
    end
    for i = 1, num do
        glow.Transparency = 0.30 - i/num/1
        wait()
    end
end

1 answer

Log in to vote
0
Answered by 8 years ago

The answer is simple. You just got some math incorrect:

glow = script.Parent
num = 30
while true do
    for i = 1, num do
        glow.Transparency = 1/(num/i)
        wait()
    end
    for i = 1, num do
        glow.Transparency = 1/(num/i)
        wait()
    end
end

You should really improve your math skills. It would help a lot.

0
it goes from 0 to 1 then instaly goes back to 0 and i want it to go from 0 to 0.30 then from 0.30 to 0... Bulvyte 388 — 8y
Ad

Answer this question