Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by
R0jym 47
2 years ago
Edited by Ziffixture 2 years 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

01local light = script.Parent.PointLight
02local bulb = script.Parent
03local day = game.Lighting.BooleanValue
04 
05while true do
06if day.Value == true then
07    bulb.Material = Enum.Material.Neon
08    light.Range = 15
09elseif day.Value == false then
10    bulb.Material = Enum.Material.SmoothPlastic
11        light.Range = 0
12        wait()
13    end
14end

1 answer

Log in to vote
0
Answered by
R0jym 47
2 years ago

Nevermind, I did this instead and it worked

01local light = script.Parent.PointLight
02local bulb = script.Parent
03local lighting = game:GetService("Lighting")
04 
05local Connection
06Connection = lighting.LightingChanged:Connect(function(LightPole)
07    if lighting.ClockTime >= 18 then
08        light.Range = 15
09        bulb.Material = Enum.Material.Neon
10elseif lighting.ClockTime >= 6 then
11        light.Range = 1
12        bulb.Material = Enum.Material.SmoothPlastic
13    end
14end)
Ad

Answer this question