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

Day of the week GUI in roblox stays at the same day and does not change?

I have tried this so far and it works, but it stays on the same day of the week and does not change which is weird because there are no errors in the output.

##Script:



local daysOfTheWeek = {
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
}

for i=1, #daysOfTheWeek do
    for _, plr in pairs(game.Players:GetPlayers()) do
        local plrGui = plr:WaitForChild("PlayerGui")
        local serverWeekGui = plrGui:WaitForChild("ServerWeekGui")
        serverWeekGui.TextLabel.Text = daysOfTheWeek[i]
    end
    while not game.Lighting.ClockTime == 0 do
        wait(1)
    end
end

What I want is for when the clock time changes to 0 for the day to change to the next day. Like say it's Monday, I want the day to change to Tuesday.

4 comments

1

Put some pride into your work. I fixed a lot of the grammatical errors and the codeblock.

0

its because of line 17 

0

what you have to do is check when the clocktime is 0 then change to the next day

0

how do i do that?

2 answers

✓ Accepted answer

It's probably a syntax error, try putting parentheses with your not on line 17 like this

while not(game.Lighting.ClockTime == 0) do

I also suggest doing this if you want your script to work after day 7

local daysOfTheWeek = {
    "Sunday",
    "Monday",
    "Tuesday",
    "Wednesday",
    "Thursday",
    "Friday",
    "Saturday"
}

for i=1, #daysOfTheWeek do
    for _, plr in pairs(game.Players:GetPlayers()) do
        local plrGui = plr:WaitForChild("PlayerGui")
        local serverWeekGui = plrGui:WaitForChild("ServerWeekGui")
        serverWeekGui.TextLabel.Text = daysOfTheWeek[i]
    end
    while not game.Lighting.ClockTime == 0 do
        wait(1)
    end

    if i == 7 then
        i = 0
    end
end

8 comments

0

i get a error at the do part

0

ah sorry I changed the answer it should work now

0

now i get this warning Infinite yield possible on 'Players.Guest_player1689.PlayerGui:WaitForChild("ServerWeekGui")'

0

Are you sure that the serverweekgui is there? Infinite yield means that it's waiting for something but it isn't appearing

0

i got rid of the warning Infinite yield but the script is still not changing the date

0

can you send any sort of image? maybe your lighting cycle script isn't hitting exactly 0 clocktime

0

heres a video https://youtu.be/dmkXZQ4m3T4 to show you that the day is not changing when clocktime is at 0 for 12 hour format 12 AM

0

what did i do wrong?

##Problem: The problem you're encountering is that you're trying to Wait for the child of "ServerWeekGui". This GUI is a screen GUI, and would not work, because you cannot change the ScreenGui.

##Solution

To resolve this, you'd simply have to index the hierarchy of the screen GUI, the (Textabel), and that would fix your error, this would index the text label, so it would actually run!

##Fixed Script:

DAY/Night cycle script: (The below script works):


local daysOfTheWeek = {
	"Sunday",
	"Monday",
	"Tuesday",
	"Wednesday",
	"Thursday",
	"Friday",
	"Saturday"
}

for z=1, #daysOfTheWeek do

	for _, plr in pairs(game.Players:GetPlayers()) do
		local plrGui = plr:WaitForChild("PlayerGui")

		local serverWeekGui = plrGui:WaitForChild("ScreenGui").TextLabel1 -- change "TextLabel1" to your textlabel name
		for i = 1, 23 do
			wait(5) -- change how fast the clocktime arises
			game.Lighting.ClockTime = i -- changes the clock time to the index
			if game.Lighting.ClockTime == i then
				serverWeekGui.Text = daysOfTheWeek[z]   -- changes the text to the days of the week
			end
		 end
	  end
  end

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