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 color of a PointLight via color of a GUI button?

I want the color of the PointLight the same color of the GUI TextButton. Help?

2 answers

✓ Accepted answer

mu has the correct answer, but his code is inefficient:

local light = workspace.Part.PointLight --set this to the PointLight object
local gui = game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame --set this to the GUI object you want to draw from.

gui.Changed:connect(function()
	light.Color = gui.BackgroundColor3 --Or, as mu said, TextColor3 or BorderColor3
end)

2 comments

1

Lmao, I just wrote the first thing that came to mind...coroutines

0

I could bash that, since using coroutine.wrap() inline is ugly. Not to say a resume wrapping a create wrapping a function is any less ugly but I digress.

Assuming you have the Script in the button and a PointLight in a part in the workspace

local Light=workspace.Part.PointLight
coroutine.wrap(function()
	while wait() do
		Light.Color=script.Parent.BackgroundColor3 --Or TextColor3, BorderColor3, etc...
	end
end)()

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