Flickering light error

I’m trying to make a flickering light script, but i’m getting an error: 21:22:11.849 - Workspace.Part.Script:5: attempt to call a Color3 value
Extra information: The part has a pointlight attached to it, and the script is in the part. It’s not a local script

local lol = true
while lol == true do
	wait(2)
	script.Parent.PointLight.Brightness = 0.3
	script.Parent.BrickColor.Color(0,0,0)
	wait(0.7)
	script.Parent.BrickColor.Color(200,200,0)
	script.Parent.PointLight.Brightness = 0.7
	wait(0.6)
	script.Parent.BrickColor.Color(255,255,0)
	script.Parent.PointLight.Brightness = 1
	wait()
	repeat
		
	until
	lol == false
end
1 Like

You will have to set the BrickColor.Color this way, I believe:

script.Parent.BrickColor.Color = Color3.fromRGB(0,0,0)
3 Likes

That won’t work as you aren’t assigning the variable. Also to set Color with Color.fromRGB() you have to do Part.Color

script.Parent.Color = Color3.fromRGB(0,0,0)

21:31:16.045 - Color cannot be assigned to

1 Like

My bad, I just realized it is a non assignable property, you could just go with what @Haydz6 has mentioned, it should work fine.

Except his script has a small error, as he has referenced Color.fromRGB, it should be Color3.fromRGB instead

2 Likes

Thank you for pointing that out.

21:33:47.756 - Script timeout: exhausted allowed execution time

You have

repeat
		
	until
	lol == false

Without a wait. Is that to try and end the while true do loop?

Alright, no errors after adding the wait() after repeat, but the color doesnt change

1 Like

It never changes again because the

repeat until lol == false

Condition is never met

If that is meant to end the loop, you can do this instead

local lol = true
while true do
    if lol == false then --if lol == true then it will not end the loop and it will continue
       break --ends the loop if lol == false and the loop will not continue
    end
	wait(2)
	script.Parent.PointLight.Brightness = 0.3
	script.Parent.BrickColor.Color(0,0,0)
	wait(0.7)
	script.Parent.BrickColor.Color(200,200,0)
	script.Parent.PointLight.Brightness = 0.7
	wait(0.6)
	script.Parent.BrickColor.Color(255,255,0)
	script.Parent.PointLight.Brightness = 1
end

I made it would never become false, so it would keep repeating, right?

Yes, I went ahead and fixed it. It will now end when lol becomes false

local lol = true
while true do
	if lol == false then
		break
	end
	wait(2)
	script.Parent.PointLight.Brightness = 0.3
	script.Parent.BrickColor.Color = Color3.fromRGB(0,0,0)
	wait(0.7)
	script.Parent.BrickColor.Color = Color3.fromRGB(200,200,0)
	script.Parent.PointLight.Brightness = 0.7
	wait(0.6)
	script.Parent.BrickColor.Color = Color3.fromRGB(255,255,0)
	script.Parent.PointLight.Brightness = 1
end

I added the Color3 thing, because it said attempt to call a color3 value, now it says 21:40:08.971 - Color cannot be assigned to again.

local lol = true
while true do
	if lol == false then
		break
	end
	wait(2)
	script.Parent.PointLight.Brightness = 0.3
	script.Parent.Color = Color3.fromRGB(0,0,0)
	wait(0.7)
	script.Parent.Color = Color3.fromRGB(200,200,0)
	script.Parent.PointLight.Brightness = 0.7
	wait(0.6)
	script.Parent.Color = Color3.fromRGB(255,255,0)
	script.Parent.PointLight.Brightness = 1
end

Accidentally took the other one, fixed it.

1 Like