function color()
while true do
if part.Material == Enum.Material.Neon then
part.BrickColor = light.Color
light.Enabled = true
else
light.Enabled = false
end
wait(0.1)
end
end
I wanna make this script turn the pointlight color of the part color but its throwing an error.
Replace BrickColor with just Color
also: For any future posts you make here - please include the actual error message as well as the line where it occurs 
Got it, that just turned the part color to my light color that’s pre-set, I need it to do the opposite.
Heres the full code:
local part = script.Parent
local light = part.PointLight
local RunService = game:GetService("RunService")
function color()
while true do
if part.Material == Enum.Material.Neon then
part.Color = light.Color
light.Enabled = true
else
light.Enabled = false
end
wait(0.1)
end
end
RunService.Heartbeat:Connect(color)
hoooooollllyyyyy memory leak.
Are you wanting to make it so the colour of the light is changed to the part colour?
I’ll rewrite the code entirely
Whats a memory leak, and I want the color of the part be the color of the pointlight.
local part = script.Parent
local light = part.PointLight
part.Changed:Connect(function()
if part.Material == Enum.Material.Neon then
part.Color = light.Color -- switch this around if you want a different outcome
light.Enabled = true
else
light.Enabled = false
end
end)
You’re creating a while loop every heartbeat. 60 odd while loops being created each second, with each firing every 0.1 seconds. Its going to result in the game having to process more and more things at once, which will cause lag
So this script will also be a memory leak?
local green = script.Parent
local light = green.PointLight
local RunService = game:GetService("RunService")
function color()
while true do
if green.Material == Enum.Material.Neon then
light.Enabled = true
else
light.Enabled = false
end
wait(0.1)
end
end
RunService.Heartbeat:Connect(color)
Yep.
You can just use the same script as I posted before, but remove the color changing line
Thanks whats the difference in loops between mine and urs?
My code is connecting it up to an event, in this case a Changed event. It will fire each time something is changed (AKA only when it needs to update)
Your code creates a while loop that checks periodically, which is less performant as it has to run the checks even when the part didn’t change. It also created a while loop 60 times a second so yeah, laggy