Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago

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?

0
Is this a local script? User#5423 17 — 8y
0
nope it isn't. Can that be why? Activatted 47 — 8y
0
@kingdom5 so I just tried with localscript it still doesnt work. Activatted 47 — 8y
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? User#5423 17 — 8y
View all comments (10 more)
0
@kingdom5 the script is inside the frame together with the textbox. Activatted 47 — 8y
0
can you print screen the hierarchy just to save some time. User#5423 17 — 8y
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. Activatted 47 — 8y
0
That will not help as, https://scriptinghelpers.org/blog/common-mistakes#PlayerGui. It is ok to put the script in the gui. User#5423 17 — 8y
0
@kingdom5 Ah you're right Activatted 47 — 8y
0
Where is the "script" located? In StarterGui I presume? And you should definitely be using a LocalScript. User#11440 120 — 8y
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. Activatted 47 — 8y
0
its not disabled is it? print(1) at the top of the script, before anything else, and see if that runs. User#11440 120 — 8y
0
Alright, so I finally figured it out. This is how the script looks like Activatted 47 — 8y
0
local text = script.Parent.TextBox print('test script running, stage 1') while true do text.Text = game.Lighting.TimeOfDay wait(.1) end Activatted 47 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
Edited 8 years ago

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
0
"note that it gives back no errors" User#11440 120 — 8y
1
thank you. It seems as if this might have been why. Activatted 47 — 8y
Ad

Answer this question