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

How do I enable a PointLight based on the Time of Day in game? [SOLVED]

Asked by 6 years ago
Edited 6 years ago

In detail, I want to enable a PointLight I inserted into a Part based on what the time it is in the game. My goal is to have PointLights around my place enabled throughout the time of night in the game. Can someone please help me, I'm very rusty and I know this is a simple task. All help is appreciated.

pLight = game.Workspace.Light.PointLight
ToD = game.Lighting.ClockTime

if ToD == 13 then
    pLight.Enabled = true
end
0
Thanks, it worked! Upvoted ReynaldoVictarion 70 — 6y

1 answer

Log in to vote
1
Answered by
GingeyLol 338 Moderation Voter
6 years ago
pLight = game.Workspace.Light.PointLight
ToD = game.Lighting.ClockTime

if ToD == 13 then
    pLight.Enabled = true
end

that will only run once

do

local time = game.Lighting.ClockTime
time.Changed:connect(function(OMGGG)
    if ToD == 13 then
    pLight.Enabled = true
    end
end)

this script runs the if statement when ClockTime is changed

Ad

Answer this question