How would I go about making a TextBox that sets ClockTime?

The title says it all. I’ve made this rough draft but it doesn’t seem to work.

local clockTime = game:GetService("Lighting").ClockTime
local textBox = script.Parent

textBox.Text = clockTime

local function changeTimeOfDay(enterPressed, inputObject)
	if enterPressed then
		textBox.PlaceholderText = ""
		clockTime = textBox.Text
		print("TimeOfDay was set!")
	else
		textBox.Text = ""
		textBox.PlaceholderText = "TimeOfDay was not set!"
	end
end

textBox.FocusLost:Connect(changeTimeOfDay)

Another thing: It prints “TimeOfDay was set!” as well. But it doesn’t set it.

2 Likes

Does it work now,

The variable should be Lighting instead of .ClockTime, or it will be just a useless display of Lighting.ClockTime

local Lighting = game:GetService("Lighting")
local textBox = script.Parent

textBox.Text = Lighting.ClockTime

local function changeTimeOfDay(enterPressed, inputObject)
	if enterPressed then
		textBox.PlaceholderText = ""
		Lighting.ClockTime = textBox.Text
		print("TimeOfDay was set!")
	else
		textBox.Text = ""
		textBox.PlaceholderText = "TimeOfDay was not set!"
	end
end

textBox.FocusLost:Connect(changeTimeOfDay)
3 Likes