Can't figure out how to detect if there is an odd number

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I am making a system that shrinks icons by a factor of two if there are more than 16.

Note:
(While it needs 16 apps to shrink, there are 2 extras due to the UIListLayout and LocalScript running this)
2. What is the issue? Include screenshots / videos if possible!
I can’t figure out how to deal with the odd numbers without messing it up.

that was a bad explanation so basically heres a video of it:

Script:

script.Parent.ChildAdded:Connect(function()
	if table.getn(script.Parent:GetChildren()) == 19 then
		local tbl = script.Parent:GetChildren()
		for _,object in pairs(tbl) do
			if object:IsA("Frame") then
				object:TweenSize(UDim2.new(object.Size.X.Scale/2,object.Size.X.Offset/2,object.Size.Y.Scale/2,object.Size.Y.Offset/2),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.75)
				game:GetService('TweenService'):Create(
					object.UIStroke,TweenInfo.new(0.75,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
				{Thickness = object.UIStroke.Thickness/2}):Play()
				game:GetService('TweenService'):Create(
					script.Parent.UIListLayout,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
				{Padding = UDim.new(script.Parent.UIListLayout.Padding.Scale/2,script.Parent.UIListLayout.Padding.Offset/2)}):Play() 
			end
		end
	end
end)
script.Parent.ChildRemoved :Connect(function()
	if table.getn(script.Parent:GetChildren()) < 19 then
		local tbl = script.Parent:GetChildren()
		for _,object in pairs(tbl) do
			if object:IsA("Frame") then
				object:TweenSize(UDim2.new(object.Size.X.Scale*2,object.Size.X.Offset*2,object.Size.Y.Scale*2,object.Size.Y.Offset*2),Enum.EasingDirection.InOut,Enum.EasingStyle.Quad,0.75)
				game:GetService('TweenService'):Create(
					object.UIStroke,TweenInfo.new(0.75,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
				{Thickness = object.UIStroke.Thickness*2}):Play()
				game:GetService('TweenService'):Create(
					script.Parent.UIListLayout,TweenInfo.new(1,Enum.EasingStyle.Linear,Enum.EasingDirection.InOut),
				{Padding = UDim.new(script.Parent.UIListLayout.Padding.Scale*2,script.Parent.UIListLayout.Padding.Offset/2)}):Play() 
			end
		end
	end
end)
if number % 2 == 0 then
	print('even')
else
	print('odd')
end

Optionally:

function IsEven(number)
	return number%2==0
end
1 Like

How would I be able to implement this into the script? Would I have to add additional if statements to it or is there a more efficient way?

Probably, though I didn’t really read much past the title of this post. I will say though, the automatic UI stuff is often unreliable from my experience.