I am trying to create Time in my game and i created working formula to count game time.
local TimeMultiple = 1
local TotalTime = 0
local Minutes = 0
local Hours = 0
local Days = 0
local Months = 0
local Years = 0
while true do
TotalTime = TotalTime + 1 * TimeMultiple
Minutes = Minutes + 1 * TimeMultiple
if Minutes >= 60 then
Hours = Hours + math.floor(Minutes / 60)
Minutes = Minutes % 60
end
if Hours >= 24 then
Days = Days + math.floor(Hours / 24)
Hours = Hours % 24
end
if Days >= 30 then
Months = Months + math.floor(Days / 30)
Days = Days % 30
end
if Months >= 12 then
Years = Years + math.floor(Months / 12)
Months = Months % 12
end
task.wait(1)
end
How do i use Variables like "Hours" "Minutes" and etc in other scripts? I need to dispay time into UI Label and i want to add admin command ;time (number) to change TimeMultiple to change time speed for testing and etc. But when i tried do these with AI it died on creating Admin Chat command, AI can help me display time into label text, but he do these kinda weird and i don't understand few things how he do that, so i trying do these for my self, but i am very new to scripting so i don't know how to create Variable which i can use in other scripts. I already searched in internet about that, i found something like "module scripts" and when i tryed to use recieve thing it give an error and says "script must return 1 of something" and i have 7 variables to return, so i have no idea how to solve these problem. Help me out please.