This is meant to chance day/night and also show it on the screen!
the ModuleScript I made,
local timer = {}
timer.__index = timer
function timer.new()
local self = setmetatable({},timer)
game.Lighting.ClockTime = 0
self.enabled = false
return self
end
function timer:Start()
self.enabled = true
coroutine.wrap(function()
while self.enabled do
game.Lighting.ClockTime += 0.01 -- Don't touch it or the Day/Night Cycle will get ruined!
local hour = math.floor(game.Lighting.ClockTime)
local hour12 = hour%13
local minute = ((game.Lighting.ClockTime - hour)*10)%60
local timePeriod = math.ceil(hour/12)
local period
if timePeriod == 2 then
period = "PM"
else
period = "AM"
end
local theString = tostring(hour12..":"..minute..period)
game:GetService("ReplicatedStorage").GlobalTime:FireAllClients(theString)
wait(0.01)
end
end)()
end
function timer:Pause()
self.enabled = false
end
the Script I used to call,
local module = require(script.ModuleScript)
The error I got,
- Module code did not return exactly one value
I am new to OOP and I don’t exactly know what value is getting returned…