Lighting GUI Script

Hey Developers!

I was wondering if anyone could help me, I’m making a system where you can press a coloured button on a GUI and it changes light parts to that colour. I have a script, but it’s changing the colour to black not the colour of the button. I would usually just define the colour but I have about 30 different buttons with different colours so I wanted to try doing it differently instead of trying to define every colour.

GUI Script

newcolor = script.Parent.BackgroundColor3

script.Parent.MouseButton1Click:Connect(function(plr)
	game.ReplicatedStorage.LightsEvent:FireServer(newcolor)
end)

Server Script

local Event = game.ReplicatedStorage.LightsEvent

Event.OnServerEvent:Connect(function(player,newcolor)
	for i,v in pairs(workspace.StageLights:GetDescendants()) do
		if v:isA("BasePart") then
			v.PointLight.Color = Color3.new(newcolor)
		end
	end
end)

Any help would be appreciated. :heart:

1 Like

Try using Color3.fromRGB() instead of Color3.new()

And remember that RGB values can be converted to normalized values by dividing them by 255 or multiplying them by 255 to be converted from normalized to RGB values.

Color3.new(173 / 255, 183 / 255, 54 / 255) -- to normalized values
Color3.fromRGB(0.6784, 0.7176, 0.2117) -- to rgb values

Yeah that didn’t work, I already tried that.

Shouldn’t BackgroundColor3 already be a Color3 value? If so then you shouldn’t need to do Color3.new(newcolor), try setting it directly to newcolor, may fix the problem.

1 Like

Ah, I’m so silly lol. Thanks for your help this worked!