I'm trying to get this to change a part's color to red or white, depending on what math.random selects (1 for red, 2 for white). The code basically works. However, the function seemingly never gets called, and the part changes to and remains black.
function light()
local nl = Instance.new("PointLight", workspace)
nl.Parent = script.Parent
nl.Color = script.Parent.Color
nl.Brightness = 2
end
while true do
wait(1)
num = math.random(1,2)
if num == 1 then
script.Parent.Color = Color3.new(255, 0, 0)
elseif num == 2 then
script.Parent.Color = Color3.new(248, 248, 248)
end
end
light()
