0

# How to fix script not working even though condition is successful? [Solved]

R0jym 14
15 days ago
Edited by Ziffixture 15 days ago

This question has been solved by the original poster.

Hello there, I tried making a script where if the BoolValue is set to true then the bulb will turn to neon and the lights will be enabled, and if the BoolValue is set to false then the bulb will become SmoothPlastic and the lights will be disabled

However it didn't worked even though it seems correct to me, what do I do? Thanks for feedbacks btw

local light = script.Parent.PointLight
local bulb = script.Parent
local day = game.Lighting.BooleanValue

while true do
if day.Value == true then
bulb.Material = Enum.Material.Neon
light.Range = 15
elseif day.Value == false then
bulb.Material = Enum.Material.SmoothPlastic
light.Range = 0
wait()
end
end



0
R0jym 14
15 days ago

Nevermind, I did this instead and it worked

local light = script.Parent.PointLight
local bulb = script.Parent
local lighting = game:GetService("Lighting")

local Connection
Connection = lighting.LightingChanged:Connect(function(LightPole)
if lighting.ClockTime >= 18 then
light.Range = 15
bulb.Material = Enum.Material.Neon
elseif lighting.ClockTime >= 6 then
light.Range = 1
bulb.Material = Enum.Material.SmoothPlastic
end
end)