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

My prison status GUI refuses to change. Why won't this loop work?

Asked by 3 years ago

I have a prison game, where there is a GUI at the top that shows the current status of the prison. I made a loop to have it change after a specific amount of time, but the text does not change at all. Any idea why? This script is in ServerScriptService.

local Status = game.StarterGui.StatusGUI.Status.Status.Text

while wait(0) do
    Status = "Hygiene Time"
    wait(90)
    Status = "Fitness Time"
    wait(120)
    Status = "Breakfast Time"
    wait(90)
    Status = "Fitness Time"
    wait(120)
    Status = "Morning Roll-Call"
    wait(90)
    Status = "Cell Searches"
    wait(90)
    Status = "Fitness Time"
    wait(120)
    Status = "Lunch"
    wait(90)
    Status = "Fitness Time"
    wait(120)
    Status = "Supper"
    wait(90)
    Status = "Fitness Time"
    wait(120)
    Status = "Evening Roll-Call"
    wait(90)
    Status = "Sleep Time"
    wait(120)
end

1 answer

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

while wait(0) do is not the correct way to do a while loop. Also, if you reference properties in the variable, it will think it is a child of the gui object.

local Status = game.StarterGui.StatusGUI.Status.Status

while true do
    Status.Text = "Hygiene Time"
    wait(90)
    Status.Text = "Fitness Time"
    wait(120)
    Status.Text = "Breakfast Time"
    wait(90)
    Status.Text = "Fitness Time"
    wait(120)
    Status.Text = "Morning Roll-Call"
    wait(90)
    Status.Text = "Cell Searches"
    wait(90)
    Status.Text = "Fitness Time"
    wait(120)
    Status.Text = "Lunch"
    wait(90)
    Status.Text = "Fitness Time"
    wait(120)
    Status.Text = "Supper"
    wait(90)
    Status.Text = "Fitness Time"
    wait(120)
    Status.Text = "Evening Roll-Call"
    wait(90)
    Status.Text = "Sleep Time"
    wait(120)
end
0
It works! Thank you! MrOinkerzYT 87 — 3y
0
No problem! LazokkYT 117 — 3y
Ad

Answer this question