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

Help with TextLabel and it's Text property?

Every time it the second reaches 0 or 1 ,2 ,3 etc, it starts flickering and changing the seconds to 0 then to the normal second,I want it to be like 00,01 and so on,how can I fix this or prevent it? Please show how you managed to fix it.

Example:

The second is 1

then it will be 01

and quickly change to 1 one again

while true do
    wait(.1)
--~--~--Varibles--~--~--~--~--
local ClientSeconds = tick()
Hour = math.floor(ClientSeconds/3600%60)
Minutes = math.floor(ClientSeconds/60%60)
Seconds = math.floor(ClientSeconds%60)
local TimeGui = script.Parent
local SecondsGui = script.Parent.Parent.Seconds
------Removes the Space between Minutes-------
if Minutes < 10
    then
 TimeGui.Text = Seconds
    TimeGui.Text = Hour..":".. "0"..Minutes--Removes space in Minutes
wait(.5)
SecondsGui.Text = Seconds
 TimeGui.Text = Hour.." ".. "0"..Minutes

else
	 TimeGui.Text = Seconds
TimeGui.Text = Hour..":"..Minutes
wait(.5)
SecondsGui.Text = Seconds
TimeGui.Text = Hour.." "..Minutes
------Removes the Space between Seconds-------
if Seconds < 10
    then
    SecondsGui.Text ="0" ..Seconds --Removes Space In Seconds
TimeGui.Text = Hour..":"..Minutes
wait(.1)
SecondsGui.Text = Seconds
TimeGui.Text = Hour.." "..Minutes
else
 TimeGui.Text = Seconds
TimeGui.Text = Hour..":"..Minutes
wait(.1)
SecondsGui.Text = Seconds
TimeGui.Text = Hour.." "..Minutes

end
end
end


1 answer

✓ Accepted answer

I fixed the flickering and a couple of problems in the script and made it look nicer (formatted better). Also removed unneeded setting of seconds text. (Seemed like you didn't want seconds to "flicker")

Script without 0 in front of seconds (no flickering):

while true do
	-- Clock was 0.5 to 0.6 seconds faster than it would be in real life
    wait(.4)
	--~--~--~-- Varibles --~--~--~--
	local ClientSeconds = tick()
	Hour = math.floor(ClientSeconds / 3600 % 60)
	Minutes = math.floor(ClientSeconds / 60 % 60)
	Seconds = math.floor(ClientSeconds % 60)
	local TimeGui = script.Parent
	local SecondsGui = script.Parent.Parent.Seconds
	---- Removes the Space between Minutes ----
	if Minutes < 10 then
		TimeGui.Text = Seconds
    	TimeGui.Text = Hour .. ":" .. "0" .. Minutes -- Removes space in Minutes
		wait(.5)
		SecondsGui.Text = Seconds
		TimeGui.Text = Hour .. " " .. "0" .. Minutes
	else
		TimeGui.Text = Seconds
		TimeGui.Text = Hour .. ":" .. Minutes
		wait(.5)
		SecondsGui.Text = Seconds
		TimeGui.Text = Hour .. " " .. Minutes
		SecondsGui.Text = Seconds
	end
end

Script with 0 in front of seconds (no flickering):

while true do
	-- Clock was 0.5 to 0.6 seconds faster than it would be in real life
    wait(.4)
	--~--~--~-- Varibles --~--~--~--
	local ClientSeconds = tick()
	Hour = math.floor(ClientSeconds / 3600 % 60)
	Minutes = math.floor(ClientSeconds / 60 % 60)
	Seconds = math.floor(ClientSeconds % 60)
	local TimeGui = script.Parent
	local SecondsGui = script.Parent.Parent.Seconds
	---- Removes the Space between Minutes ----
	if Minutes < 10 then
		TimeGui.Text = Seconds
    	TimeGui.Text = Hour .. ":" .. "0" .. Minutes -- Removes space in Minutes
		wait(.5)
		SecondsGui.Text = Seconds
		TimeGui.Text = Hour .. " " .. "0" .. Minutes
	else
		TimeGui.Text = Seconds
		TimeGui.Text = Hour .. ":" .. Minutes
		wait(.5)
		SecondsGui.Text = Seconds
		TimeGui.Text = Hour .. " " .. Minutes
		---- Removes the Space between Seconds ----
		if Seconds < 10 then
			SecondsGui.Text = "0" .. Seconds -- Put a zero in front of seconds
		else
			SecondsGui.Text = Seconds
		end
	end
end

Screenshot of GUI setup I made for testing: http://puu.sh/9M2j1/9f05959796.jpg

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