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

Help with neatness and organization?

I want to make this code smaller,but I don't know anyway. Please,show you how manged to make organize it and give tips if you can. (:

while true do
	wait(.1)
--~--~--Varibles--~--~--~--~--
local ClientSeconds = tick()
Hour = math.floor(ClientSeconds/3600)
Minutes = math.floor(ClientSeconds/60%60)
Seconds = math.floor(ClientSeconds%60)
local TimeGui = script.Parent
local SecondsGui = script.Parent.Parent.Seconds
------------Table for Numbers with no space-----
NumbersWithNoSpace = {0,1,2,3,4,5,6,7,8,9}--Numbers with no space
------Removes the Space between Minutes-------
if Minutes == 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9--Removes space in Minutes
	then
	TimeGui.Text = Hour..":"..Minutes.."0"
else
	TimeGui.Text = Hour..":"..Minutes
------Removes the Space between Seconds-------
if Seconds == 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 or 8 or 9 --Removes Space In Seconds
	then
	SecondsGui.Text = Seconds.."0"
else
	SecondsGui.Text = Seconds
-------------Main Time Controller-------------
TimeGui.Text = Seconds
TimeGui.Text = Hour..":"..Minutes
wait(.1)
SecondsGui.Text = Seconds
TimeGui.Text = Hour.." "..Minutes
-----------------------------------------------
end
end
end

1 answer

Here, I sort of fixed it for you:

while true do
	wait()
	--~--~--Varibles--~--~--~--~--
	local ClientSeconds = tick()
	Hour = math.floor(ClientSeconds/3600)
	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-------
	TimeGui.Text = Hour..":"..(tostring(Minutes:len()) == 1 and ("0"..Minutes) or Minutes) --Using a ternary operation to get rid of the big conditional
	------Removes the Space between Seconds-------
	SecondsGui.Text = (tostring(Seconds:len()) == 1 and ("0"..Seconds) or Seconds)
	-------------Main Time Controller-------------
	SecondsGui.Text = Seconds
	TimeGui.Text = Hour..":"..Minutes
	wait(.1)
	SecondsGui.Text = Seconds
	TimeGui.Text = Hour.." "..Minutes
end

I also fixed some minor errors that I saw, so it should work fine now. Hope this helped!

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