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

Hi how do I change the transparency of my baseplate?

Asked by
iznr 0
5 years ago
i = 0

Base = game.Workspace.Baseplate

Base.BrickColor = BrickColor.new("Really red")

while true do

wait(0.1)

Base.Transparency = i

i = i + 0.01

if i > 1 then

i = i - 0.02

print(0)

end

end

i'm not sure how i can revert back my transparency after the baseplate goes to 1

2 answers

Log in to vote
0
Answered by 5 years ago

Try putting a while loop in your if statement, cause right now, you're only telling it to subtract 0.02 from i only when i is greater than one. So when the while loop starts again, it would add 0.01 back to i, but that. So to fix that:

if i > 1 then
    while true do
    wait(0.01)
    i = i- 0.02
    Base.Transparency = i
    if i < 0 then
        break
    end
end
0
oops there should be another end for the while loop. Just add another end at the end of the script kevinliwu1 9 — 5y
Ad
Log in to vote
0
Answered by
Fad99 286 Moderation Voter
5 years ago

What you are doing is checking if the base plates transparency goes over one then -.02. But after that you add another .01 because its in a while loop. So it will be stuck at near 1. you have to make sure that the base plate goes back down to zero before it starts adding again.

i = 0
Base = game.Workspace.Baseplate
Base.BrickColor = BrickColor.new("Really red")

while true do

    wait(0.1)
    Base.Transparency = i
    i = i + 0.01

    if i >= 1 then
    repeat
        i = i -.02
    until i <= 0

        print(0)
    end
end
0
The Repeat Until loop just repeats a certain block of code until the condition after the "Until" is met, in this case i will subtract until its less than or equal to zero. Then it will break out of the repeat loop and continue to while loop Fad99 286 — 5y

Answer this question