Parts of my script is being ignored

Hey.

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.

Thank you.

1 Like

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.

1 Like

Try this one

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

Thank you both. It works now :sweat_smile:

It’s just one of those days :joy:

1 Like

np man, sometimes the brain just stops braining, I get that too

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.