local rStorage = game:GetService("ReplicatedStorage")
local startTime = rStorage:WaitForChild("ServerStartTime")
local cafe = workspace:WaitForChild("Cafe")
local tv = cafe:WaitForChild("TV")
local serverInfoPart = tv:WaitForChild("ServerInfoPart")
local surfaceGui = serverInfoPart:WaitForChild("SurfaceGui")
local serverAgeText = surfaceGui:WaitForChild("ServerAgeText")
function FormatTime(seconds)
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local secs = math.floor(seconds % 60)
return string.format("%d hours, %d minutes, and %d seconds", hours, minutes, secs)
end
function UpdateLabel()
while true do
local currentTime = tick()
local elapsedTime = currentTime - startTime.Value
serverAgeText.Text = FormatTime(elapsedTime)
task.wait(1)
end
end
UpdateLabel()
For testing purposes i made my own version and it works as intended?
local startTime = tick()
function FormatTime(seconds)
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local secs = math.floor(seconds % 60)
return string.format("%d hours, %d minutes, and %d seconds", hours, minutes, secs)
end
function UpdateLabel()
while true do
local elapsedTime = tick() - startTime
print(FormatTime(elapsedTime))
task.wait(1)
end
end
UpdateLabel()
Make sure the value inside of startTime.Value is initialized on server Startup
so basically
local rStorage = game:GetService("ReplicatedStorage")
local startTime = rStorage:WaitForChild("ServerStartTime")
local cafe = workspace:WaitForChild("Cafe")
local tv = cafe:WaitForChild("TV")
local serverInfoPart = tv:WaitForChild("ServerInfoPart")
local surfaceGui = serverInfoPart:WaitForChild("SurfaceGui")
local serverAgeText = surfaceGui:WaitForChild("ServerAgeText")
function FormatTime(seconds)
local hours = math.floor(seconds / 3600)
local minutes = math.floor((seconds % 3600) / 60)
local secs = math.floor(seconds % 60)
return string.format("%d hours, %d minutes, and %d seconds", hours, minutes, secs)
end
function UpdateLabel()
while true do
local currentTime = tick()
local elapsedTime = currentTime - startTime.Value
serverAgeText.Text = FormatTime(elapsedTime)
task.wait(1)
end
end
startTime.Value = tick() -- Initialize The startTime.Value to the current Tick [On Startup]
UpdateLabel()