Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Trying to change a TextLabel to TimeOfDay?

So I have this Day/Night cycle code I made, and I was wondering what I could add to this to make it change text in a TextLabel.

Here is my code:

local interval = 0.4
local change = 0.01

while wait(interval) do
	game.Lighting.ClockTime = game.Lighting.ClockTime + change
end

Any help is appreciated!

2 answers

✓ Accepted answer
-- Client Script

local Players = game:GetService("Players") -- Player Service
local Lighting = game:GetService("Lighting") -- Lighting Service

local LocalPlayer = Players.LocalPlayer -- Our Client
local PlayerGui = LocalPlayer.PlayerGui -- Our Gui path, StarterGui clones it to here for each player.
 
local Gui = PlayerGui.ScreenGui -- Our Gui
local TextLabel = Gui.TextLabel -- Our Textlabel to change.

local Interval, Change = .5, .01 -- Declaring our Variables

while wait(Interval) do -- while loop.
    Lighting.ClockTime = Lighting.ClockTime + Change -- Setting new time
	TextLabel.Text = ("%s"):format(Lighting.TimeOfDay) -- Set textlabel to time.
end

:) Hope this has helped in any shape.

1 comment

0

Thanks! :) Unable to test rn, but will get back when I can.

This is Simple Just create a script inside the TextLabel and copy the code below into it.

game:GetService("RunService").Stepped:Connect(function() --A loop
	script.Parent.Text = "Time: "..game.Lighting.ClockTime --Changes Text of TextLabel to Clock Time
end)

This discussion is preserved as it was. New answers, comments, and votes are closed.