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

My Monday-Sunday Day Script doesn't seem to work? Any idea why?

Asked by 5 years ago
 --/Variables

--//All weekdays. Why you would add any more I don't know, but it is easy to do.
local WeekDays = {
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday",
    "Sunday"
}

--//Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Lighting = game:GetService("Lighting")

--//If the values don't exist create them
local CurrentTime = ReplicatedStorage:FindFirstChild("CurrentClockTime")
if not CurrentTime then 
    CurrentTime = Instance.new("StringValue", ReplicatedStorage)
    CurrentTime.Name = "CurrentClockTime"
end

local CurrentWeekDayValue = ReplicatedStorage:FindFirstChild("CurrentWeekDay")
if not CurrentWeekDayValue then 
    local CurrentWeekDayValue = Instance.new("StringValue", ReplicatedStorage)
    CurrentWeekDayValue.Name = "CurrentWeekDay"
end

--//Variables for internal script usage
local CurrentWeekDay = 1
local Hours = 0
local Minutes = 0

--//Config
local DebugEnabled = false
local DayNightCycleEnabled = true
local RiseAndShineMessageEnabled = true
local LoopWeekDays = true

--/Running Logic

while true do
    for i = 1, 24 do
        for i = 1, 60 do
            wait(1)
            Minutes = Minutes + 1
            CurrentTime.Value = (function() if string.len(tostring(Hours)) == 1 then return "0"..tostring(Hours) else return tostring(Hours) end end)()..":"..(function() if string.len(tostring(Minutes)) == 1 then return "0"..tostring(Minutes) else return tostring(Minutes) end end)()
            if DebugEnabled then
                print(CurrentTime.Value)
            end
            if DayNightCycleEnabled then
                Lighting.TimeOfDay = CurrentTime.Value
            end
        end
        Hours = Hours + 1
    end
    if WeekDays[CurrentWeekDay] == nil and LoopWeekDays then
        CurrentWeekDay = 1
    else
        CurrentWeekDay = CurrentWeekDay + 1
    end
    if RiseAndShineMessageEnabled then
        print("Rise and shine! It's", CurrentWeekDayValue.Value)
    end
    CurrentWeekDayValue.Value = WeekDays[CurrentWeekDay]
end
0
Looks excessively complicated, what exactly are you hoping to do? xXGokyXx 46 — 5y
0
For every time 24 minutes pass, it changes the day. Example: 1st day:Monday, Tuesday, and so on. 2Westy2 2 — 5y

Answer this question