Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Making a clock, trying to find out what to do to prevent a 10 from appearing in the 1st digit?

For a game I'm trying to develop, I am trying to make a functional clock at the top of the screen. There are 3 different Text labels to adjust the minutes, and 2 digits for the seconds. When running, whenever the clock hits a flat 10 value in the seconds section the 10 will remain on the first digit. For example, if the time were to be going 6:42, 6:41 to 6:40, it would instead show 6:3 10. I am using this script with a NumValue in ReplicatedStorage. What should I go about doing to make sure the last digit never becomes a flat out 10 and to revert ten back to the 2nd digit?

local TimerValue = game.ReplicatedStorage.TimerValue.Value


-- 	script.Parent.Seconds.Text = 		print(ThirdDigitFinal)  Stored code for later

if script.Parent.Seconds2.Text == 10 then
	script.Parent.Seconds2.Text = 0
end

while TimerValue > 0 do
	wait(1)
	TimerValue = TimerValue - 1
	game.ReplicatedStorage.TimerValue.Value = TimerValue - 1
	local TimerValue = game.ReplicatedStorage.TimerValue.Value
	local MinutesRough = game.ReplicatedStorage.TimerValue.Value/60
	local Minutes = tostring(math.floor(MinutesRough))
	local SecondsDecimated = MinutesRough - Minutes
	local Seconds = SecondsDecimated * 60
	local Seconds2nd = tostring(math.floor(Seconds/10))
	local Seconds3rd = Seconds/10
	local ThirdDigit = Seconds3rd - Seconds2nd
	local ThirdDigitFin = ThirdDigit * 10
	local ThirdDigitFinal = tostring(math.ceil(ThirdDigitFin))
	script.Parent.Seconds2.Text = ThirdDigitFinal
	script.Parent.Minute.Text = Minutes
	script.Parent.Seconds.Text = Seconds2nd
	print(ThirdDigitFinal)
end


2 comments

0

Why are you using two TextBoxs for the seconds? Wouldn’t just using one work.

0

I used two because I couldn't find a way to keep a zero in front of the text value with just one, it left the values going something like this: 3:11, 3:10, 3:9, 3:8

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.