|
| 16 Dec 2015 07:36 PM |
while true do wait(0.1) if game.Workspace.Timer.Value == 0 then script.Parent.Parent.ImageLabel.Visible = false script.Parent.Parent.Time.Visible = false else script.Parent.Parent.ImageLabel.Visible = true script.Parent.Parent.Time.Visible = true end end
while true do wait() script.Parent.Text = game.Workspace.Timer.Value end
? |
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 16 Dec 2015 07:38 PM |
This doesn't work because the first loop never ends so the second loop will never be run
However, there is a better method to do all of this
workspace:WaitForChild("Timer") workspace.Timer.Changed:connect(function() if game.Workspace.Timer.Value == 0 then script.Parent.Parent.ImageLabel.Visible = false script.Parent.Parent.Time.Visible = false else script.Parent.Parent.ImageLabel.Visible = true script.Parent.Parent.Time.Visible = true end
script.Parent.Text = workspace.Timer.Value end) |
|
|
| Report Abuse |
|
|
| |
|
XIPokezIX
|
  |
| Joined: 24 Sep 2015 |
| Total Posts: 381 |
|
|
| 16 Dec 2015 07:44 PM |
while true do wait(0.1) if game.Workspace.Timer.Value == 0 then script.Parent.Parent.ImageLabel.Visible = false script.Parent.Parent.Time.Visible = false elseif game.Workspace.Timer.Value>0 then script.Parent.Parent.ImageLabel.Visible = true script.Parent.Parent.Time.Visible = true end end
spawn(function() while true do wait(0.1) script.Parent.Text=game.Workspace.Timer.Value end) |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2015 07:46 PM |
rvoxs script only works if you have a NumberValue/IntValue object in your game.
~Cutting someone down at the knees doesn't make you any taller~ |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2015 07:47 PM |
Same with yours, so that may be your first concern, look for every Object named "Timer" in your workspace and see what shows!
~Cutting someone down at the knees doesn't make you any taller~ |
|
|
| Report Abuse |
|
|
rvox
|
  |
| Joined: 18 Feb 2011 |
| Total Posts: 5380 |
|
|
| 16 Dec 2015 07:49 PM |
Well I'm assuming that there is such a thing in workspace, since it's in the original script
i do not think there's anything wrong with mine, post errors? |
|
|
| Report Abuse |
|
|
|
| 16 Dec 2015 08:28 PM |
well, it's an intvalue named Timer and what's suppose to happen is it counts down from 60 when the round starts.
Idk the problem |
|
|
| Report Abuse |
|
|
|
| 17 Dec 2015 03:28 PM |
Let's break this down slowly: While true loops never end, so anything that's after will never run, unless you break the loop using..well.. break in the loop. So the first loop may very well be working, but we can't see it working. And because we want the loop that displays the timers value to always loop at a rate of 1/60th of a second (without a number wait() will always yield for a single frame, or 1/60th of a second). we need to have one loop. so what I would personally do is make the first while loop a function called "timerChange" Secondly we need to Make a debounce so instead of it changing every frame, it will change in 0.1 seconds. This is done easily with a bool variable. At the top of your code place this:
local debounce = false
The third step is to implement this debounce. So cut out the code inside the timerChange function and place this there instead:
if debounce == false then debounce = true wait(0.1) if game.Workspace.Timer.Value == 0 then script.Parent.Parent.ImageLabel.Visible = false script.Parent.Parent.Time.Visible = false else script.Parent.Parent.ImageLabel.Visible = true script.Parent.Parent.Time.Visible = true end debounce = false end
I'm assuming at this point another script lowers the timer, if so this is all you'll need, By the end your code will look like this:
--Beginning of the code
local debounce = false
function timeChange() if debounce == false then debounce = true wait(0.1) if game.Workspace.Timer.Value == 0 then script.Parent.Parent.ImageLabel.Visible = false script.Parent.Parent.Time.Visible = false else script.Parent.Parent.ImageLabel.Visible = true script.Parent.Parent.Time.Visible = true end debounce = false end end
while true do wait() timeChange() script.Parent.Text = game.Workspace.Timer.Value end
--End of the code
~Cutting someone down at the knees doesn't make you any taller~ |
|
|
| Report Abuse |
|
|