Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

My light changing countdown script is not working. It looks clean to me. Help?

Asked by 5 years ago

I'm trying to make a countdown light for a racing game my friend is making. I've tried to write a script that looks clean on its own but ends up not working. No errors come out in the output. Any help?

By the way, here is the code.

--variables

local lightpart = script.Parent.Parent.Parent.Light

local light = lightpart.PointLight

--script

script.Parent.MouseClick:Connect(function()

    wait(1)

    lightpart.BrickColor = "Bright red"

    wait(1)

    lightpart.BrickColor = "Bright yellow"

    wait(1)

    lightpart.BrickColor = "Sea green"

    wait(4)

    lightpart.BrickColor = "Medium stone grey"

    end)

2 answers

Log in to vote
0
Answered by
Nefarioum 162
5 years ago

The first thing I say when someone says they had no error output is are you sure you are not using a local script. Make sure if you are making changes to anything in the workspace that you are working on a normal script.

Secondly, if you are trying to change the colour of a Point Light, you will need to make use of the Color3 type. What you are doing now is trying to give it a string. This would be a solution if you paired it with the BrickColor type however this doesn't work with Point Lights as they do not have BrickColours.

So to fix your script, we will be utilising Color3.fromRGB(). You will need to begin with changing the lightpart.BrickColor to lightpart.Color for all 4 as BrickColor isn't a property in Point Lights. You will then need to find RGB values for each colour. You can do this by googling "color picker" and taking the 3 RGB numbers.

I have found the appropriate colours for you and have left the fixed version of the code below. I hope you understood and wish you all the best :)

local lightpart = script.Parent.Parent.Parent.Light
local light = lightpart.PointLight

script.Parent.MouseClick:Connect(function() -- Make sure the parent of the script is a ClickDetector for this to work 
    wait(1)
    lightpart.Color = Color3.fromRGB(235, 64, 52)
    wait(1)
    lightpart.Color = Color3.fromRGB(251, 255, 0)
    wait(1)
    lightpart.Color = Color3.fromRGB(68, 255, 0)
    wait(4)
    lightpart.Color = Color3.fromRGB(181, 181, 179)
end)
Ad
Log in to vote
0
Answered by
kazeks123 195
5 years ago
Edited 5 years ago

I don't know, why your script doesn't error out, but according to dev page: BrickColor-Codes , you should be using:

lightpart.BrickColor = BrickColor.new("Bright red")

or

lightpart.BrickColor = BrickColor.new(21)

or

lightpart.BrickColor = BrickColor.new(196, 40, 28)

or BasePart/Color

lightpart.Color = Color3.fromRGB(196, 40, 28) --Here you can actually do your own custom colors, e.g., (255,0,0) would be red, (0,255,0) - green and (0,0,255) - blue
0
This will help me in the future. Thanks! AviaCheddar 41 — 5y

Answer this question