#i want my lightpoles to only "work" at night.
1 messages · Page 1 of 1 (latest)
oh okay
local Lighting = game:GetService("Lighting")
local streetLightsFolder = workspace:WaitForChild("StreetLights")
local dayLength = 15 -- Duration of day in seconds
local nightLength = 15 -- Duration of night in seconds
local nightStart = 18 -- 6 PM
local nightEnd = 6 -- 6 AM
local function updateLights()
local currentTime = Lighting:GetMinutesAfterMidnight() / 60
for _, lightPole in ipairs(streetLightsFolder:GetChildren()) do
local light = lightPole:FindFirstChildOfClass("Light")
if light then
if currentTime >= nightStart or currentTime < nightEnd then
light.Enabled = true
else
light.Enabled = false
end
end
end
end
while true do
-- Day time: 6 AM to 6 PM
for i = 6 * 60, 18 * 60 do
Lighting:SetMinutesAfterMidnight(i)
updateLights()
wait(dayLength / (12 * 60))
end
-- Night time: 6 PM to 6 AM
for i = 18 * 60, 24 * 60 do
Lighting:SetMinutesAfterMidnight(i)
updateLights()
wait(nightLength / (12 * 60))
end
for i = 0, 6 * 60 do
Lighting:SetMinutesAfterMidnight(i)
updateLights()
wait(nightLength / (12 * 60))
end
end
oh uh
and i have puted the lightpoles in a folder
yea i highkey dont know everything looks correct
u probably misplaced something 😭 🙏
yea 1s though i have my own issue i gotta post
** You are now Level 1! **
okay doaky
** You are now Level 1! **
im back
okay
whats your user
highkey bro
do you mind waiting until tomorrow
its like 430 am rn and i have to wake up at 8
if you add me ill fs be able to help u tmr
bet just dm me whenever youre available
Youre calculqting minutes but then using hours in the operators?
what do i put in there insted?
This video concludes the series on making a day/night cycle by covering how to make a street light turn on during the night. To do this, we will use if statements inside the while loop to check the time of day.