I have spent a lot of time to make this and it not working( output don’t count its as an error so I guess I dunno)\
script:
local lightingpart = script.Parent.Light
local light = lightingpart.SpotLight.Enabled
local times = game.Lighting.ClockTime
while true do
if times >= 17.8 or times <= 6.7 then
light = true
lightingpart.Material = "Neon"
elseif times <= 17.8 or times >= 6.7 then
light = false
lightingpart.Material = "SmoothPlastic"
end
wait(1)
end
I can’t find any error in my own script
I’m not a programmer and I am not good at it.
any reply is appreciated
I’m a noob
local lightingpart = script.Parent.Light
local light = lightingpart.SpotLight
while true do
times = game.Lighting.ClockTime
if times >= 17.8 or times <= 6.7 then
light.Enabled = true
lightingpart.Material = "Neon"
else
light.Enabled = false
lightingpart.Material = "SmoothPlastic"
end
wait(1)
end
local parent = script.Parent
local lightingpart = parent:WaitForChild("Light")
local light = lightingpart:WaitForChild("SpotLight")
local lighting = game:GetService("Lighting")
while task.wait(1) do
if lighting.ClockTime >= 17.8 or lighting.ClockTime <= 6.7 then
light.Enabled = true
lightingpart.Material = "Neon"
elseif lighting.ClockTime <= 17.8 or lighting.ClockTime >= 6.7 then
light.Enabled = false
lightingpart.Material = "SmoothPlastic"
end
end
Try this as it is more efficient since it fires if the property changes and not every sec.
local lightingpart = script.Parent.Light
local light = lightingpart.SpotLight.Enabled
lighting:GetPropertyChangedSignal("ClockTime"):Connect(function()
local times = game.Lighting.ClockTime
if times >= 18 or times <= 6 then
light = true
lightingpart.Material = "Neon"
elseif times <= 18 or times >= 6 then
light = false
lightingpart.Material = "SmoothPlastic"
end
end)