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

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

Asked by 3 years ago
Edited by JesseSong 3 years ago

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.

1
Put some pride into your work. I fixed a lot of the grammatical errors and the codeblock. JesseSong 3916 — 3y
0
its because of line 17  JesseSong 3916 — 3y
0
what you have to do is check when the clocktime is 0 then change to the next day JesseSong 3916 — 3y
0
how do i do that? Guest_player1689 2 — 3y

2 answers

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

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

0
i get a error at the do part Guest_player1689 2 — 3y
0
ah sorry I changed the answer it should work now holamii2 45 — 3y
0
now i get this warning Infinite yield possible on 'Players.Guest_player1689.PlayerGui:WaitForChild("ServerWeekGui")' Guest_player1689 2 — 3y
0
Are you sure that the serverweekgui is there? Infinite yield means that it's waiting for something but it isn't appearing holamii2 45 — 3y
View all comments (4 more)
0
i got rid of the warning Infinite yield but the script is still not changing the date Guest_player1689 2 — 3y
0
can you send any sort of image? maybe your lighting cycle script isn't hitting exactly 0 clocktime holamii2 45 — 3y
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 Guest_player1689 2 — 3y
0
what did i do wrong? Guest_player1689 2 — 3y
Ad
Log in to vote
0
Answered by
JesseSong 3916 Moderation Voter Community Moderator
3 years ago

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

Answer this question