Hey y’all, so today I’ve been working on a day and night system for my game but ran into another issue. When trying to change my time of day, I noticed that the string value holding the information wasn’t changing as intended. I don’t believe this feature was out of my skillset, but now I’m just left confused as to why it isn’t working correctly. Any help figuring this out will be greatly appreciated <3
Server Script:
local WeekDay = game.ReplicatedStorage.WeekDay
local Lighting = game:GetService("Lighting")
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local globalVariables = require(ReplicatedStorage.Modules.globalVariables)
local dayDuration = 720 -- How many real-time seconds an in-game day will last
local nightDuration = 720 -- How many real-time seconds an in-game night will last
local WeekDay = ReplicatedStorage.WeekDay
local TimeOfDay = ReplicatedStorage.TimeOfDay
Lighting.ClockTime = 6
--Tween
function tween(l, p)
TweenService:Create(Lighting, TweenInfo.new(l, Enum.EasingStyle.Linear, Enum.EasingDirection.In), p):Play()
end
--Change the day of the week
function changeWeekDay()
globalVariables.currentWeekDay += 1
if globalVariables.currentWeekDay > 6 then
globalVariables.currentWeekDay = 0
end
WeekDay.Value = globalVariables.weekDays[globalVariables.currentWeekDay]
--print(globalVariables.weekDays[globalVariables.currentWeekDay])
end
function changeTimeOfDay()
globalVariables.currentTime += 1
if globalVariables.currentTime > 5 then
globalVariables.currentTime = 0
end
TimeOfDay.Value = globalVariables.timesOfDay[globalVariables.currentTime]
--print(globalVariables.timesOfDay[globalVariables.currentTime])
end
--Tween colors
while type(dayDuration) == "number" and type(nightDuration) == "number" do
--Change the day of the week and time
if Lighting.ClockTime == 0 then
changeWeekDay()
elseif Lighting.ClockTime == 6 then
changeTimeOfDay()
elseif Lighting.ClockTime == 6.5 then
changeTimeOfDay()
elseif Lighting.ClockTime == 12 then
changeTimeOfDay()
elseif Lighting.ClockTime == 17 then
changeTimeOfDay()
elseif Lighting.ClockTime == 17.5 then
changeTimeOfDay()
elseif Lighting.ClockTime == 18.2 then
changeTimeOfDay()
end
-- Change colors only with 'LightingFix' enabled
tween(4, { OutdoorAmbient = Color3.fromRGB(60, 60, 60), FogColor = Color3.fromRGB(25, 25, 25), FogEnd = 250 })
tween(nightDuration, { ClockTime = 24 })
wait(nightDuration)
tween(nightDuration, { ClockTime = 6 })
wait(nightDuration)
-- Change colors only with 'LightingFix' enabled
tween(4, { OutdoorAmbient = Color3.fromRGB(140, 140, 140), FogColor = Color3.fromRGB(149, 195, 208), FogEnd = 750 })
end
Module Script:
local globalVariables = {}
--Ready Variables
globalVariables.statsReady = false
globalVariables.gatchimonReady = false
globalVariables.movesReady = false
globalVariables.abilitiesReady = false
globalVariables.itemsReady = false
globalVariables.Ready = false
--Overworld
globalVariables.currentTime = 0
globalVariables.currentWeekDay = 0
--Misc.
globalVariables.progress = nil
--Languages
globalVariables.English = false
globalVariables.LATAMSpanish = false
globalVariables.EUSpanish = false
globalVariables.LATAMPortugese = false
globalVariables.EUPortugese = false
globalVariables.French = false
--Dictionaries
globalVariables.Gatchimon = {
Stats = { "HP", "STA", "ATK", "DEF", "MA", "SPD" },
}
globalVariables.timesOfDay = { "Dawn", "Morning", "Afternoon", "Evening", "Dusk", "Night" }
globalVariables.weekDays = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" }
return globalVariables
