I’m creating a stopwatch script, and it isn’t working quite right.
Here is the layout:
ScreenGui
NumberValue (Named as Time)
TextLabel
LocalScript
Now, whatever I make NumberValue is what TextLabel starts as, and I want that to be 0.
But I have noticed it only will count up to double the original number, which, for 0, is 0.
Script:
local seconds = script.Parent.Parent.Time
On the topbar, there should be a symbol that looks like this “</>”, highlight the text that you want formatted and click that button (sorry if this wasn’t very clear)
local seconds = script.Parent.Parent.Time
script.Parent.Text = seconds.Value
while wait(1) do
seconds.Value = seconds.Value + 1
script.Parent.Text = seconds.Value
if --the stopwatch stop button is clicked
then --put this then in the line above, i put it here to not confuse you with the comment
break
end
end
This is what i would try doing, I’m not sure if it would work.
--[ Variables
local val = --path your numbervalue
local text = --path your textlabel
local stop = --path your stop button
local paused = false
--[ Setup
stop.Activated:Connect(function()
if not paused then
paused = true
else
paused = false
end
end)
while wait(1) do
if not paused then
val.Value += 1
text.Text = val.Value
end
end