Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a light fade in and fade out on it's own?

So basically, I have a gemstone's light to fade in and fade out on an endless loop, a bit like a glowing effect. However, the script I'm using is not working. Here is the script I am using:

local light = script.Parent --Makes the script parent have a nickname: light
T = true
while T == true do
	for i = 0,5,0.1 do
		light.Brightness = i
		wait(1)
	end
	for i = 5,0,0.1 do
		light.Brightness = i
		wait(1)
	end
end

The script parent is the Pointlight. Any reasons why this isn't working?

4 comments

0

Are there any errors in the output? For the second for loop, you don't reduce the increment. So for the second part, it just goes up 5.1, 5.2, 5.3, until it reaches 0 which is never.

0

Yes, for the second for loop it should be 'for i = 5,0,-0,1'

0

Still doesn't work. Did I put it in the wrong place?

0

"for i = 5, 0, -0.1" It was just a typo. I posted the change edited into the script.

1 answer


local light = script.Parent
T = true
while T == true do
    for i = 0,5,0.1 do
        light.Brightness = i
        wait(1)
    end
    for i = 5,0,-0.1 do --This value here should be negative, signifying that it is decreasing i.
        light.Brightness = i
        wait(1)
    end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.