|
| 10 Jan 2014 06:37 PM |
Ok so the BoolValue ClockRunning actually works, but the number ones don't change... (This is in a GUI)
local ClockRunning = game.Workspace.GameScript.ClockRunning local SValue = game.Workspace.GameScript.Seconds local MValue = game.Workspace.GameScript.Minutes
game.Workspace.GameScript.Minutes.Value = 3 game.Workspace.GameScript.Seconds.Value = 0
timer = script.Parent s = game.Workspace.GameScript.Seconds m = game.Workspace.GameScript.Minutes
while ClockRunning.Value == true do wait(1) SValue.Value = SValue.Value - 1 if SValue.Value < 0 then SValue.Value = 59 MValue.Value = MValue.Value - 1 end end
while true do if s.Value < 10 then secondsString = "0".. s.Value elseif s.Value >= 10 then secondsString = s.Value end timer.Text = m.Value ..":".. secondsString wait(1) end
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jan 2014 06:38 PM |
| The first loop will never end unless it is false. |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Jan 2014 06:40 PM |
| Aaaaaaand I realised I can't do this because I can't have multiple players changing a single value in Workspace... nevermind |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2014 06:40 PM |
2 things
local SValue = game.Workspace.GameScript.Seconds local MValue = game.Workspace.GameScript.Minutes s = game.Workspace.GameScript.Seconds m = game.Workspace.GameScript.Minutes
Why?
2nd, if you're using timer.Text to see if the values are working, well, lets just say you'll never see it change because THE CODE IS STUCK IN THE FIRST LOOP. |
|
|
| Report Abuse |
|
|
| |
|
|
| 10 Jan 2014 06:45 PM |
Oh wait I should mention hehe..
ClockRunning is false by default, and is later changed in the script as mentioned my orig post called "GameScript"
|
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jan 2014 06:45 PM |
| Make sure it is changed before you create the loop |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2014 06:46 PM |
| Well then. The script will never run the first loop because there is no reason the script should go back to the first loop after it is executed. |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2014 06:46 PM |
| So uh how can I fix that?... |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2014 06:47 PM |
Throw the entire thing into a while loop. And also put the second loop as a function instead. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 10 Jan 2014 06:48 PM |
local ClockRunning = game.Workspace.GameScript.ClockRunning local SValue = game.Workspace.GameScript.Seconds local MValue = game.Workspace.GameScript.Minutes
game.Workspace.GameScript.Minutes.Value = 3 game.Workspace.GameScript.Seconds.Value = 0
timer = script.Parent s = game.Workspace.GameScript.Seconds m = game.Workspace.GameScript.Minutes
ClockRunning.Changed:connect(function(val) while val == true do wait(1) SValue.Value = SValue.Value - 1 if SValue.Value < 0 then SValue.Value = 59 MValue.Value = MValue.Value - 1 end end)
while true do if s.Value < 10 then secondsString = "0".. s.Value elseif s.Value >= 10 then secondsString = s.Value end timer.Text = m.Value ..":".. secondsString wait(1) end |
|
|
| Report Abuse |
|
|
|
| 10 Jan 2014 07:19 PM |
Ok quick question
Should "ClockRunning.Changed:connect(function(val)" be "ClockRunning.Value.Changed..." since the definition of ClockRunning doesn't include ".Value"
|
|
|
| Report Abuse |
|
|
| |
|