local l={}local function d(l,d,Z)l[d]=Z end function l.isAnInstance(l)local d,Z=pcall(Game.IsA,l,"\073\110\115\116\097\110\099\101")return Z==true end function l.isALibrary(l)if pcall(function()assert(type(l.GetApi)=="\102\117\110\099\116\105\111\110")end)then local d,Z=pcall(string.dump,l.GetApi)return Z=="\117\110\097\098\108\101 \116\111 \100\117\109\112 \103\105\118\101\110 \102\117\110\099\116\105\111\110"end return false end function l.isAnEnum(l)return pcall(Enum.Material.GetEnumItems,l)==true end function l.coerceIntoEnum(d,Z)if l.isAnEnum(Z)then for l,Z in next,Z:GetEnumItems()do if d==Z or d==Z.Name or d==Z.Value then return Z end end else error("\084\104\101 \'\101\110\117\109\' \097\114\103\117\109\101\110\116 \109\117\115\116 \098\101 \097\110 \101\110\117\109\046",2)end error("\084\104\101 \118\097\108\117\101 \099\097\110\110\111\116 \098\101 \099\111\101\114\099\101\100 \105\110\116\111 \097 \101\110\117\109 \105\116\101\109 \111\102 \116\104\101 \115\112\101\099\105\102\105\101\100 \116\121\112\101\046",2)end function l.isOfEnumType(d,Z)if l.isAnEnum(Z)then return pcall(l.coerceIntoEnum,d,Z)==true else error("\084\104\101 \'\101\110\117\109\' \097\114\103\117\109\101\110\116 \109\117\115\116 \098\101 \097\110 \101\110\117\109\046",2)end end local Z=Instance.new("\067\111\108\111\114\051\086\097\108\117\101")function l.isAColor3(l)return pcall(d,Z,"\086\097\108\117\101",l)==true end local z=Instance.new("\067\070\114\097\109\101\086\097\108\117\101")function l.isACoordinateFrame(l)return pcall(d,z,"\086\097\108\117\101",l)==true end local w=Instance.new("\066\114\105\099\107\067\111\108\111\114\086\097\108\117\101")function l.isABrickColor(l)return pcall(d,w,"\086\097\108\117\101",l)==true end local J=Instance.new("\082\097\121\086\097\108\117\101")function l.isARay(l)return pcall(d,J,"\086\097\108\117\101",l)==true end local n=Instance.new("\086\101\099\116\111\114\051\086\097\108\117\101")function l.isAVector3(l)return pcall(d,n,"\086\097\108\117\101",l)==true end function l.isAVector2(l)return pcall(function()return Vector2.new()+l end)==true end local c=Instance.new("\070\114\097\109\101")function l.isAUdim2(l)return pcall(d,c,"\080\111\115\105\116\105\111\110",l)==true end function l.isAUDim(l)return pcall(function()return UDim.new()+l end)==true end local f=Instance.new("\065\114\099\072\097\110\100\108\101\115")function l.isAAxis(l)return pcall(d,f,"\065\120\101\115",l)==true end local Q=Instance.new("\072\097\110\100\108\101\115")function l.isAFace(l)return pcall(d,Q,"\070\097\099\101\115",l)==true end function l.isASignal(l)local d,Z=pcall(function()return Game.AllowedGearTypeChanged.connect(l)end)if d and Z then Z:disconnect()return true end end function l.getType(d)local Z=type(d)if Z=="\117\115\101\114\100\097\116\097"then if l.isAnInstance(d)then return d.ClassName elseif l.isAColor3(d)then return"\067\111\108\111\114\051"elseif l.isACoordinateFrame(d)then return"\067\070\114\097\109\101"elseif l.isABrickColor(d)then return"\066\114\105\099\107\067\111\108\111\114"elseif l.isAUDim2(d)then return"\085\068\105\109\050"elseif l.isAUDim(d)then return"\085\068\105\109"elseif l.isAVector3(d)then return"\086\101\099\116\111\114\051"elseif l.isAVector2(d)then return"\086\101\099\116\111\114\050"elseif l.isARay(d)then return"\082\097\121"elseif l.isAnEnum(d)then return"\069\110\117\109"elseif l.isASignal(d)then return"\082\066\088\083\099\114\105\112\116\083\105\103\110\097\108"elseif l.isALibrary(d)then return"\082\098\120\076\105\098\114\097\114\121"elseif l.isAAxis(d)then return"\065\120\101\115"elseif l.isAFace(d)then return"\070\097\099\101\115"end else return Z end end function l.isAnInt(l)return type(l)=="\110\117\109\098\101\114"and l%1==1 end function l.isPositiveInt(l)return type(value)=="\110\117\109\098\101\114"and(l>0 and math.floor(l)==l)end function l.isAnArray(d)if type(d)=="\116\097\098\108\101"then local Z=0 local z=0 for d,w in next,d do if l.isPositiveInt(d)then Z=math.max(Z,d)z=z+1 else return false end end return Z==z else return false end end return l



local lib = {}

local function set(object, property, value)
	-- Sets the 'property' property of 'object' to 'value'.
	-- This is used with pcall to avoid creating functions needlessly.
	object[property] = value
end

function lib.isAnInstance(value)
	-- Returns whether 'value' is an Instance value.
	local _, result = pcall(Game.IsA, value, 'Instance')
	return result == true
end

function lib.isALibrary(value)
	-- Returns whether 'value' is a RbxLibrary.
	-- Finds its result by checking whether the value's GetApi function (if it has one) can be dumped (and therefore is a non-Lua function).
	if pcall(function() assert(type(value.GetApi) == 'function') end) then -- Check if the value has a GetApi function.
		local success, result = pcall(string.dump, value.GetApi) -- Try to dump the GetApi function.
		return result == "unable to dump given function" -- Return whether the GetApi function could be dumped.
	end
	return false
end

function lib.isAnEnum(value)
	-- Returns whether the value is an enum.
	return pcall(Enum.Material.GetEnumItems, value) == true
end

function lib.coerceIntoEnum(value, enum)
	-- Coerces a value into an enum item, if possible, throws an error otherwise.
	if lib.isAnEnum(enum) then
		for _, enum_item in next, enum:GetEnumItems() do
			if value == enum_item or value == enum_item.Name or value == enum_item.Value then return enum_item end
		end
	else
		error("The 'enum' argument must be an enum.", 2)
	end
	error("The value cannot be coerced into a enum item of the specified type.", 2)
end

function lib.isOfEnumType(value, enum)
	-- Returns whether 'value' is coercible into an enum item of the type 'enum'.
	if lib.isAnEnum(enum) then
		return pcall(lib.coerceIntoEnum, value, enum) == true
	else
		error("The 'enum' argument must be an enum.", 2)
	end
end

local Color3Value = Instance.new('Color3Value')
function lib.isAColor3(value)
	-- Returns whether 'value' is a Color3 value.
	return pcall(set, Color3Value, 'Value', value) == true
end

local CFrameValue = Instance.new('CFrameValue')
function lib.isACoordinateFrame(value)
	-- Returns whether 'value' is a CFrame value.
	return pcall(set, CFrameValue, 'Value', value) == true
end

local BrickColor3Value = Instance.new('BrickColorValue')
function lib.isABrickColor(value)
	-- Returns whether 'value' is a BrickColor value.
	return pcall(set, BrickColor3Value, 'Value', value) == true
end

local RayValue = Instance.new('RayValue')
function lib.isARay(value)
	-- Returns whether 'value' is a Ray value.
	return pcall(set, RayValue, 'Value', value) == true
end

local Vector3Value = Instance.new('Vector3Value')
function lib.isAVector3(value)
	-- Returns whether 'value' is a Vector3 value.
	return pcall(set, Vector3Value, 'Value', value) == true
end

function lib.isAVector2(value)
	-- Returns whether 'value' is a Vector2 value.
	return pcall(function() return Vector2.new() + value end) == true
end

local FrameValue = Instance.new('Frame')
function lib.isAUdim2(value)
	-- Returns whether 'value' is a UDim2 value.
	return pcall(set, FrameValue, 'Position', value) == true
end

function lib.isAUDim(value)
	-- Returns whether 'value' is a UDim value.
	return pcall(function() return UDim.new() + value end) == true
end

local ArcHandleValue = Instance.new('ArcHandles')
function lib.isAAxis(value)
	-- Returns whether 'value' is an Axes value.
	return pcall(set, ArcHandleValue, 'Axes', value) == true
end

local FaceValue = Instance.new('Handles')
function lib.isAFace(value)
	-- Returns whether 'value' is a Faces value.
	return pcall(set, FaceValue, 'Faces', value) == true
end

function lib.isASignal(value)
	-- Returns whether 'value' is a RBXScriptSignal.
	local success, connection = pcall(function() return Game.AllowedGearTypeChanged.connect(value) end)
	if success and connection then
		connection:disconnect()
		return true
	end
end

	
function lib.getType(value)
	-- Returns the most specific obtainable type of a value it can.
	-- Useful for error messages or anything that is meant to be shown to the user.

	local valueType = type(value)

	if valueType == 'userdata' then
		if lib.isAnInstance(value) then return value.ClassName
		elseif lib.isAColor3(value) then return 'Color3'
		elseif lib.isACoordinateFrame(value) then return 'CFrame'
		elseif lib.isABrickColor(value) then return 'BrickColor'
		elseif lib.isAUDim2(value) then return 'UDim2'
		elseif lib.isAUDim(value) then return 'UDim'
		elseif lib.isAVector3(value) then return 'Vector3'
		elseif lib.isAVector2(value) then return 'Vector2'
		elseif lib.isARay(value) then return 'Ray'
		elseif lib.isAnEnum(value) then return 'Enum'
		elseif lib.isASignal(value) then return 'RBXScriptSignal'
		elseif lib.isALibrary(value) then return 'RbxLibrary'
		elseif lib.isAAxis(value) then return 'Axes'
		elseif lib.isAFace(value) then return 'Faces'
		end
	else
		return valueType;
	end
end

function lib.isAnInt(value)
	-- Returns whether 'value' is an interger or not
	return type(value) == "number" and value % 1 == 1;
end


function lib.isPositiveInt(number)
	-- Returns whether 'value' is a positive interger or not.  
	-- Useful for money transactions, and is used in the method isAnArray ( )
	return type(value) == "number" and number > 0 and math.floor(number) == number
end


function lib.isAnArray(value)
	-- Returns if 'value' is an array or not

	if type(value) == "table" then
		local maxNumber = 0;
		local totalCount = 0;

		for index, _ in next, value do
			if lib.isPositiveInt(index) then
				maxNumber = math.max(maxNumber, index)
				totalCount = totalCount + 1
			else
				return false;
			end
		end

		return maxNumber == totalCount;
	else
		return false;
	end
end

return lib
