I’ve typed up a quick and simple script for a part so the transparency is being changed every 2 seconds. For some reason, it only executes the first couple of lines but then ignores the rest. It is still looping though, as I added a print statement which continuously printed a word. Any ideas why it won’t work?
local part = script.Parent
while true do
part.Transparency = 0
wait(2)
part.Transparency = 1 -- This line won't execute, so the part's transparency won't change.
end
I’m trying to make simple traffic lights, but the amber light stays on because of this issue.
It is executing, you just haven’t added a delay before the loop restarts. Essentially, you set the transparency to 0, wait 2 seconds, set it to 1, and then immediately set it back to 0.
local part = script.Parent
while true do
part.Transparency = 0
wait(2)
part.Transparency = 1
wait(2) -- without this one it will automatically goes to 0 again as there would be no delay
end