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

Soo, Im trying to make a gui clock off of the TimeOfDay property but it isn't working?

Here is what I tried

while true do
	script.Parent.TextBox.Text = game.Lighting.TimeOfDay
	wait(1)
	print("script true")
end

note that it gives back no errors, but it still doesn't print the "script true" so it means the loop doesn't even go that far. Can anyone help me solve this?

14 comments

0

Is this a local script?

0

nope it isn't. Can that be why?

0

@kingdom5 so I just tried with localscript it still doesnt work.

0

You should use a local script , add a print to the top of the to check that it is being ran. Also where is this script?

0

@kingdom5 the script is inside the frame together with the textbox.

0

can you print screen the hierarchy just to save some time.

0

Nevermind, I got it to work. What I did was just to make a script in workspace, made a "while true do" loop and did game.StarterGui.ScreenGui.Frame.TextBox.Text = game.Lighting.TimeOfDay and that worked.

0

That will not help as, https://scriptinghelpers.org/blog/common-mistakes#PlayerGui. It is ok to put the script in the gui.

0

@kingdom5 Ah you're right

0

Where is the "script" located? In StarterGui I presume? And you should definitely be using a LocalScript.

0

@wfvj014 Script is located right here: https://gyazo.com/478341d20973c8a5f2d6178ddccf05d5 but it seems to not even respond to print if I use a localscript.

0

its not disabled is it? print(1) at the top of the script, before anything else, and see if that runs.

0

Alright, so I finally figured it out. This is how the script looks like

0

local text = script.Parent.TextBox print('test script running, stage 1') while true do text.Text = game.Lighting.TimeOfDay wait(.1) end

1 answer

✓ Accepted answer

It's possible that the script is trying to run before the TextBox loads, or that it can't find the Lighting service (less likely). Try this:

local textBox = script.Parent:WaitForChild("TextBox");
local lighting = game:GetService("Lighting");
while true do
    textBox.Text = lighting.TimeOfDay
    wait(1)
    print("script true")
end

2 comments

0

"note that it gives back no errors"

1

thank you. It seems as if this might have been why.

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