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.
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
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