Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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


1 answer

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)



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