I want to make a stopwatch and my script looks fine but it isn't.
local frame = script.Parent
local ifPause = frame.pauseAppear
local StartButton = frame.Start
local ResetButton = frame.Reset
local timeText = frame:WaitForChild("Time")
local secondsVal = frame.Seconds
local seconds = 0
local minutes = 0
local hours = 0
timeText.Text = "0:00:00"
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input, gameProcessed)
if input.KeyCode == Enum.KeyCode.Q then
ifPause.Value = not ifPause.Value
if ifPause.Value == true then
while wait(1)do
print("seconds going up")
secondsVal.Value = secondsVal.Value + 1
if secondsVal.Value == 60 then
minutes = minutes + 1
secondsVal.Value = 0
end
if secondsVal.Value < 10 then
if minutes < 10 then
timeText.Text = hours..":0"..minutes..":0"..secondsVal.Value
else
timeText.Text = hours..":"..minutes..":0"..secondsVal.Value
end
else
if minutes < 10 then
timeText.Text = hours..":0"..minutes..":"..secondsVal.Value
else
timeText.Text = hours..":"..minutes..":"..secondsVal.Value
end
end
ifPause.Value = true
end
else
print("VALUE IS FALSE!!")
local currentVal = secondsVal.Value
print(currentVal.." VS "..secondsVal.Value --//Prints
while secondsVal.Value ~= currentVal do
print(currentVal.." VS2 "..secondsVal.Value) --//Does not print and I don't know why.
end
end
end
end)
Also I think this way of doing it is not a good way. It would help if you gave me ideas to do it a better way?
Thanks alot for taking your time in reading my message

2 comments
The line 47 on your fixed one didn't work
As I already commented on the fixed version, it doesn't print to the console, however, it works perfectly fine displaying to a GUI.