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

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

Log in to vote
0
Answered by
R0jym 47
2 years 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)



Ad

Answer this question