Basically, I was toying with some transparency scripts and wanted to try doing a transparency fading script. This was my attempt:
if script.Parent.Transparency < 1 then script.Parent.Transparency = script.Parent.Transparency + 0.1 else script.Parent.Transparency = 0 end
For whatever reason, it's not working. I'm not getting errors or anything in the output. Can anybody explain or correct my script?
You're not looping through the if statement. Therefore, it will only run once on execution.
Put the code in a while loop. In fact, you could just place the logic in the while loop as well. while (condition(s) (is/are) true) do
. This way you don't even need the while loop.
while wait() and script.Parent.Transparency < 1 do --While waiting 1/30 of a second on top of the Transparency still being less than 1, continue with the loop. script.Parent.Transparency = script.Parent.Transparency + .1 --Add .1 to Transparency and set that as the new transparency. end
As a reminder, Gui elements should be handled by LocalScripts.