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

Is this the right Day/Night script?

Asked by 10 years ago
while true do
game.Workspace.Lighting.TimeOfDay=15:00:00
wait(50)
game.Workspace.Lighting.TimeOfDay=14:00:00
wait(50)
game.Workspace.Lighting.TimeOfDay=13:00:00
wait(50)
game.Workspace.Lighting.TimeOfDay=12:00:00
wait(50)
game.Workspace.Lighting.TimeOfDay=11:00:00
wait(50)
game.Workspace.Lighting.TimeOfDay=7:00:000
wait(50)
end

2 answers

Log in to vote
-1
Answered by 10 years ago

no this is the right script

-- dayLength defines how long, in minutes, a day in your game is. Feel free to alter it.
local dayLength = 12

local cycleTime = dayLength*60
local minutesInADay = 24*60

local lighting = game:GetService("Lighting")

local startTime = tick() - (lighting:getMinutesAfterMidnight() / minutesInADay)*cycleTime
local endTime = startTime + cycleTime

local timeRatio = minutesInADay / cycleTime

if dayLength == 0 then
    dayLength = 1
end

repeat
    local currentTime = tick()

    if currentTime > endTime then
        startTime = endTime
        endTime = startTime + cycleTime
    end

    lighting:setMinutesAfterMidnight((currentTime - startTime)*timeRatio)
    wait(1/15)
until false

Ad
Log in to vote
-3
Answered by 10 years ago

I believe so

0
No wait, don't have .Workspace, just lighting NinjoOnline 1146 — 10y
0
wow thats a lot of dislikes :/ It works for me if you get rid of the workspace NinjoOnline 1146 — 10y

Answer this question