This system is supposed to update a GUI by the name of “TimeGUI” to show up on top as a clock. However, despite timeLabel existing within the path described, it continuously warns that it doesn’t exist, and I don’t have the slightest clue as to why…
Below you’ll find a snippet of what’s causing this.
Locals
local replicatedStorage = game:GetService("ReplicatedStorage")
local players = game:GetService("Players")
local localPlayer = players.LocalPlayer
local playerGui = localPlayer:WaitForChild("PlayerGui")
local timeValue = replicatedStorage.Time
local timeGui = playerGui:WaitForChild("TimeGUI")
local timeLabel = timeGui:WaitForChild("timeLabel")
local function updateTime()
wait(1)
playerGui.TimeGUI.timeLabel = tostring(timeValue)
end
timeValue.Changed:Connect(updateTime)
Serverscript
local module = {}
local starterGui = game:GetService("StarterGui")
local timeGui = starterGui.TimeGUI
local replicatedStorage = game:GetService("ReplicatedStorage")
local timeValue = replicatedStorage.Time
local Players = game:GetService("Players")
local MA = "AM"
local RunService = game:GetService("RunService")
local LG = game:GetService("Lighting")
local sunTime = 0
local function ChangeAM(num)
if num <= 12 then
MA = "AM"
elseif num > 12 then
MA = "PM"
end
if num % 3 == 0 then
for i = sunTime,num,0.05 do
RunService.Heartbeat:Wait()
sunTime = i
LG.ClockTime = sunTime
end
end
end
local function FormatHour(num)
if num > 12 then
return tostring(num - 12)
else
return tostring(num)
end
end
local function FormatNumber(num)
if num <= 9 then
return "0"..tostring(num)
else
return tostring(num)
end
end
local function FormatDay(num)
num = num + 1
local days = {"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"}
return days[num]
end
function module:StartTime()
while true do
for d = 0,6,1 do
for h = 1,24,1 do
ChangeAM(h)
for m = 0,59,1 do
for s = 0,59,1 do
local formattedTime = FormatHour(h)..":"..FormatNumber(m)..":"..FormatNumber(s).." "..MA
local formattedDay = FormatDay(d)
game.ReplicatedStorage.Time.Value = formattedTime
game.ReplicatedStorage.Day.Value = formattedDay
RunService.Heartbeat:Wait()
end
end
end
end
end
end
return module