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

Wait until Changed doesn't work?

Asked by 8 years ago

I have a script that waits until a certain value is changed, senses the change, then counts down. When the count down is done, it opens a lobby that players can join and leave as they please. However, the script seems to be unresponsive, and the count down never happens. I don't know exactly the problem, but I'm assuming its the "changed" command, as that's where the script seems to stop. Also, it doesn't give me any problems in output, it just seems to stop working at that part for whatever reason. Here's the script:

a = game.Workspace.Values.CurrentRace
game.StarterGui:WaitForChild("HUD")
print("got it")

a.Changed:connect(function()
    if a.Value == "none" then
        game.Players.LocalPlayer.PlayerGui.HUD.CurrentRace.Text = "Next Race Starts in:"
        local time = 5
        for i = 1, 5 do
            wait(1)
            time = time - 1
            game.Players.LocalPlayer.PlayerGui.HUD.Countdown.Text = tostring(time)
        end
        print("done")
        game.Workspace.Values.CurrentRace.Value = "lobby"
    end
end)

There is a separate script that changes the "CurrentRace" value, and yes, that script works fine. Its just this script that breaks. One more thing: 90% of my questions on this website relate to problems like this, as I always have problems with these types of scripts. So if you could give me any advice on how to troubleshoot and attempt to manually fix problems related to these types of scripts, that would be awesome!

All help is greatly appreciated!

1
print out the value of a before line 6 and see what it returns, if that doesn't print lmk. I figure you know this but just incase make sure that its a string value and the value is case-sensitive, also, is it really none? or do you just want to check if there is no value, if so just change "none" to "" dragonkeeper467 453 — 8y
0
"none" is that name that the value is changed to. Basically, that value starts out blank, then after 5 seconds, it changes to "none". Thats what this script is supposed to be sensing ZeMeNbUiLdEr 104 — 8y
0
The names and locations of all the values your using would be helpful. AwsomeSpongebob 350 — 8y

Answer this question