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

How to make turn on PointLight at night in torso of player and turn off when it's day?

Asked by 2 years ago
Edited 2 years ago

I tried to make this LocalScript at StarterCharacterScripts but it's not working..

local PointLight = Instance.new("PointLight", script.Parent.Torso)
PointLight.Enabled = false
PointLight.Range = 50
PointLight.Brightness = 2
PointLight.Shadows = true

if game.Lighting.ClockTime >= 22 then
    PointLight.Enabled = true
else
    if game.Lighting.ClockTime >= 8 then
        PointLight.Enabled = false
    end
end

1 answer

Log in to vote
0
Answered by 2 years ago

Put it in a loop so that the script will constantly check the time.

while true do
    if game.Lighting.ClockTime >= 22 then
        PointLight.Enabled = true
    elseif game.Lighting.ClockTime >= 8 then
        PointLight.Enabled = false
    end
    task.wait()
end
0
Thank you very much! It's actually works! SoftBlueApple 12 — 2y
Ad

Answer this question