I’m a expert in building and designing but an complete noob when it comes to scripting/coding so you might see my name pop up alot this year (so be warned hahaha)
What I want to achieve
I want to create it where the time and date on the GUI changes when the clock hits midnight
I manage to make the clock work however I don’t know how to make the date change and the day too, I want it so it rotates though the month (up to 30 days then goes back to 1st when it passes 30th) and the day too (Monday to Sunday and reset back to Monday when it passes Sunday)
If anyone could walk me though this problem or show me where to find this information I would be very grateful
Are you working on this in the real time or ingame? You can use “and” “or” operators to determine the time and later just change the textcolor3 of the guilabels.
You could make two values in lighting, one of them contains the days of the week, and the other the days of the month (Both IntValues and set as 1)
You could set a script which identifies when the time in lighting is 0:00, if the time is 0, then one point will be added to both values.
You must set a script, which sets a max value:
local DaysOfTheWeek = game:GetService("Lighting"):FindFirstChild("DotW")
local DaysOfTheMonth = game:GetService("Lighting"):FindFirstChild("DotM")
DaysOfTheWeek.Changed:Connect(function()
if DaysOfTheWeek.Value > 7 then --If sunday passed.
DaysOfTheWeek.Value = 1
end
end)
DaysOfTheMonth.Changed:Connect(function()
if DaysOfTheMonth.Value > 31 then --If it's 32th
DaysOfTheWeek.Value = 1 --Back to 1
end
end)
And in the gui, you could set this:
local DaysOfTheWeekText = script.Parent:FindFirstChild("DotW")
local DaysOfTheMonthText = script.Parent:FindFirstChild("DotM")
local DaysOfTheWeek = game:GetService("Lighting"):FindFirstChild("DotW")
local DaysOfTheMonth = game:GetService("Lighting"):FindFirstChild("DotM")
DaysOfTheMonthText.Text = DaysOfTheMonth.Value
DaysOfTheWeekText.Text = DaysOfTheWeek.Value
DaysOfTheMonth.Changed:Connect(function()
DaysOfTheMonthText.Text = DaysOfTheMonth.Value
end)
DaysOfTheWeek.Changed:Connect(function()
DaysOfTheWeekText.Text = DaysOfTheWeek.Value
end)
Ok, later, you must write or find a code which does a day/night cycle, and that stuff. I hope this helps
In that case you want to use the lightning.clocktime to determine whenever it is night or day, I would look at trying to see which numbers work the best for you (the clocktime maxes out at 24 so midnight would be 0 while noon would be 12). This helps you to stay away from the TimeOfDay as it now feels obselete for these kinds of things.
Once you have the periods which you want it to be a certain color, simply create conditional statements to change the color of the gui text. You can use tween service to create much more cleaner transition.
Here are some helpful resources in case you are stuck, developer.roblox.com is a really helpful since it also has alot of tutorials that can come in handy.