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 add the light colour to this?

local LightPart = workspace.Park
script.Parent.MouseButton1Click:connect(function()
	if LightPart:findFirstChild(LightPart.Name..'Light') then
		LightPart:findFirstChild(LightPart.Name..'Light'):Destroy()
		script.Parent.Text = 'Press to turn light on'
	else
		local light = Instance.new("PointLight", LightPart)
		light.Name = LightPart.Name..'Light'
		light.Range = 30
		script.Parent.Text = 'Press to turn light off'
	end
end)

When I turn the light on it is white. If I try going in "Play Solo" I turn the light on and edit the colour. When I turn it on and off again it goes back to white. Can someone suggestion something I need to add on the script and where to add it.

2 answers

Every time you run the script, you are deleting the old light and creating a new light. You have to re-enter in all the info of the light when creating a new one. Put in this after line 9...

light.Color = BrickColor.new("New yeller") --Or whatever you use to change the color

1 comment

0

Wrong. Look at my answer to see what is wrong with yours

local LightPart = workspace.Park
script.Parent.MouseButton1Click:connect(function()
    if LightPart:findFirstChild(LightPart.Name..'Light') then
        LightPart:findFirstChild(LightPart.Name..'Light'):Destroy()
        script.Parent.Text = 'Press to turn light on'
    else
        local light = Instance.new("PointLight", LightPart)
        light.Name = LightPart.Name..'Light'
        light.Range = 30
        script.Parent.Text = 'Press to turn light off'
	light.Color = Color3.new(r/255,g/255,b/255) --Change r to tone of red g to tone of green b to tone of blue
    end
end)

OR If you want to use a brickcolor do this

local LightPart = workspace.Park
script.Parent.MouseButton1Click:connect(function()
    if LightPart:findFirstChild(LightPart.Name..'Light') then
        LightPart:findFirstChild(LightPart.Name..'Light'):Destroy()
        script.Parent.Text = 'Press to turn light on'
    else
        local light = Instance.new("PointLight", LightPart)
        light.Name = LightPart.Name..'Light'
        light.Range = 30
        script.Parent.Text = 'Press to turn light off'
	light.Color = BrickColor.new("Bright blue").Color
    end
end)

There! It converts BrickColor into Color3

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