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

How do I change the colour of this light?

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.

Script:

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)

2 answers

✓ Accepted answer
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
	light.Color=Color3.new(1/255,2/255,3/255)--Here find the color3 you want, and replace the 1 2 or 3, but keep the /255 that keeps the color you want
        script.Parent.Text = 'Press to turn light off'
    end
end)

1 comment

1

For clarity on Color3: The properties tab shows a number out of 255, but Color.new takes numbers 0 to 1. So normally we divide the integer we see in the Properties tab by 255 to scale it for Color3.new.

Well you don't even need to use a script for this, just edit the light's color in its properties in "edit" mode. You can just place it in workspace, and then when you change the color property of the pointlight, you can see it. Afterwards, any changes you make are permanent.

2 comments

0

@painzx, It is a gui script I want it to operate via a gui because I'm making a car.

0

Oh ok then. I thought it was a tool

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