I'm trying to script a part that endlessly fades in and out, slowly changing from 0 Transparency to 1 Transparency, then back to 0, and so on.
Below is what I've come up with, but there is no effect on the part when I run or play. No errors show in the output.
cubeTransparency = game.Workspace.Cube.Transparency while true do for i = 0,1,0.1 do cubeTransparency = i wait(0.2) end wait(0.01) end
Any help or advice would be greatly appreciated!
Your transparency doesn't change because the variable holds the current transparency. It doesn't effect the Part's transparency. It would only override the variable.
-- Add a local so you won't pollute the global scope -- Let's say the Cube's transparency is 0 local cubeTransparency = game.Workspace.Cube.Transparency -- Only overrides the variable. It wouldn't effect the actual transparency. cubeTransparency = 1 print(game.Workspace.Cube) --> 0 print(cubeTransparency) -->1
Here is the final code.
local Cube = game.Workspace.Cube while true do for Transparency = 0,1,0.1 do Cube.Transparency = Transparency wait(0.2) end wait(0.01) end