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

How do I change the colour of this light? [closed]

Asked by
Danfly 5
10 years ago

This question already has an answer here:

How do I add the light colour to this?

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)

Marked as Duplicate by AmericanStripes

This question has been asked before, and already has an answer. If those answers do not fully address your question, then please ask a new question here.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 10 years ago
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
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`. BlueTaslem 18071 — 10y
Ad
Log in to vote
0
Answered by
painzx3 43
10 years ago

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.

0
@painzx, It is a gui script I want it to operate via a gui because I'm making a car. Danfly 5 — 10y
0
Oh ok then. I thought it was a tool painzx3 43 — 10y