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

When enabling and unenabling sound, get get the printed outputs, but script dosent work?

Asked by 4 years ago

in the code below, it finds a sound, and it detects weither or not its enabled. Both prints how up when I enable and unable it, but the transparency never changes.

if script.Parent.Parent.Handle.Output.FireSound.Playing == true then
    while true do
    script.Parent.Transparency = 1
    wait(0.1)
    script.Parent.Transparency = 0
    end
    print("Flashing")

else
script.Parent.Transparency = 1
print("Off")
end


0
Comment: Everything is set up right to, yet nothing still works Adenandpuppy 87 — 4y
0
It shouldn't even be reaching the print("Flashing") due to the while true statement. Robowon1 323 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

Your issue is with the way your while statement is setup. You're never waiting after the second transparency change so it's immediately running the loop again changing the transparency back. Easy fix. Just insert another wait.

while true do
    script.Parent.Transparency = 1
    wait(.1)
    script.Parent.Transparency = 0
    wait(.1)
end
Ad

Answer this question