local X=game:GetService("\084\101\120\116\083\101\114\118\105\099\101")local w=game:GetService("\084\119\101\101\110\083\101\114\118\105\099\101")local G=TweenInfo.new(.15)local F={}function F.new(F,E,j)local I={Duration=F.Duration;Value=j,Labels=table.create(10);CanvasTweens=table.create(10)}local c=TweenInfo.new(F.Duration)local f=Instance.new("\070\114\097\109\101")f.Name="\100\105\103\105\116"f.LayoutOrder=E f.BackgroundTransparency=1 f.Size=UDim2.new(0,0,0,F.TextSize+6)f.ClipsDescendants=true local V=Instance.new("\070\114\097\109\101")V.Name="\099\097\110\118\097\115"V.Size=UDim2.new(1,0,10,0)V.BackgroundTransparency=1 V.Parent=f V.Position=UDim2.new(0,0,-I.Value,0)for X=0,9,1 do local G=Instance.new("\084\101\120\116\076\097\098\101\108")G.Name="\110\095"..X G.BackgroundTransparency=1 G.TextSize=F.TextSize G.TextColor3=F.TextColor3 G.Font=F.Font G.Text=X G.Size=UDim2.new(1,0,.1,0)G.Position=UDim2.new(0,0,X*.1,0)G.Parent=V I.Labels[X]=G I.CanvasTweens[X]=w:Create(V,c,{Position=UDim2.new(0,0,-X,0)})end f.Parent=F.Frame local i=X:GetTextSize("\056",F.TextSize,F.Font,Vector2.new(F.TextSize,F.TextSize));(w:Create(f,G,{Size=UDim2.new(0,i.X+1,0,i.Y+10)})):Play()local C=setmetatable({},{__index=function(X,w)local G=I[w]if G then return G end local F=pcall(function()local X=I.Labels[1][w]end)if F then return I.Labels[1][w]end return nil end;__newindex=function(X,w,G)local F=I[w]if F then I[w]=G I:Update(w,G)return end local E=pcall(function()local X=I.Labels[1][w]end)if E then for X=0,9,1 do I.Labels[X][w]=G end I:Update(w,G)end end})function I.Destroy(E)local j=X:GetTextSize("\056",F.TextSize,F.Font,Vector2.new(F.TextSize,F.TextSize))local c=w:Create(f,G,{Size=UDim2.new(0,0,0,j.Y+10)})c.Completed:Connect(function()f:Destroy()table.clear(I)c:Destroy()end)c:Play()end function I.Update(i,E,j)if E=="\068\117\114\097\116\105\111\110"then c=TweenInfo.new(j)for X=0,9,1 do I.CanvasTweens[X]=w:Create(V,c,{Position=UDim2.new(0,0,-X,0)})end elseif E=="\086\097\108\117\101"then I.CanvasTweens[j]:Play()elseif E=="\084\101\120\116\083\105\122\101"or E=="\070\111\110\116"then local E=X:GetTextSize("\056",F.TextSize,F.Font,Vector2.new(F.TextSize,F.TextSize));(w:Create(f,G,{Size=UDim2.new(0,E.X+1,0,E.Y+10)})):Play()end end return C end return F
local TextService = game:GetService("TextService")
local TweenService = game:GetService("TweenService")

local sizeTweenInfo = TweenInfo.new(0.15)

local Digit = {}

function Digit.new(Spinner, LayoutOrder, Value)
	local d = {
		Duration = Spinner.Duration,
		Value = Value,

		Labels = table.create(10),
		CanvasTweens = table.create(10),
	}
	local tweenInfo = TweenInfo.new(Spinner.Duration)

	local Frame = Instance.new("Frame")
	Frame.Name = "digit"
	Frame.LayoutOrder = LayoutOrder
	Frame.BackgroundTransparency = 1
	Frame.Size = UDim2.new(0, 0, 0, Spinner.TextSize + 6)
	Frame.ClipsDescendants = true

	local Canvas = Instance.new("Frame")
	Canvas.Name = "canvas"
	Canvas.Size = UDim2.new(1, 0, 10, 0)
	Canvas.BackgroundTransparency = 1
	Canvas.Parent = Frame

	Canvas.Position = UDim2.new(0, 0, -d.Value, 0)

	for i = 0, 9 do
		local n = Instance.new("TextLabel")
		n.Name = "n_" .. i
		n.BackgroundTransparency = 1
		n.TextSize = Spinner.TextSize
		n.TextColor3 = Spinner.TextColor3
		n.Font = Spinner.Font
		n.Text = i
		n.Size = UDim2.new(1, 0, 0.1, 0)
		n.Position = UDim2.new(0, 0, i * 0.1, 0)
		n.Parent = Canvas
		d.Labels[i] = n
		d.CanvasTweens[i] = TweenService:Create(Canvas, tweenInfo, { Position = UDim2.new(0, 0, -i, 0) })
	end

	Frame.Parent = Spinner.Frame

	local Size =
		TextService:GetTextSize("8", Spinner.TextSize, Spinner.Font, Vector2.new(Spinner.TextSize, Spinner.TextSize))
	TweenService:Create(Frame, sizeTweenInfo, { Size = UDim2.new(0, Size.X + 1, 0, Size.Y + 10) }):Play()

	local dProxy = setmetatable({}, {
		__index = function(_, key)
			local Direct = d[key]
			if Direct then
				return Direct
			end

			local Success = pcall(function()
				local _x = d.Labels[1][key]
			end)
			if Success then
				return d.Labels[1][key]
			end

			return nil
		end,
		__newindex = function(_, key, value)
			local Direct = d[key]
			if Direct then
				d[key] = value
				d:Update(key, value)
				return
			end

			local Success = pcall(function()
				local _x = d.Labels[1][key]
			end)
			if Success then
				for i = 0, 9 do
					d.Labels[i][key] = value
				end
				d:Update(key, value)
			end
		end,
	})

	function d:Destroy()
		local _Size = TextService:GetTextSize(
			"8",
			Spinner.TextSize,
			Spinner.Font,
			Vector2.new(Spinner.TextSize, Spinner.TextSize)
		)
		local shrinkTween = TweenService:Create(Frame, sizeTweenInfo, { Size = UDim2.new(0, 0, 0, _Size.Y + 10) })
		shrinkTween.Completed:Connect(function()
			Frame:Destroy()
			table.clear(d)
			shrinkTween:Destroy()
		end)
		shrinkTween:Play()
	end

	function d:Update(Type, _Value)
		if Type == "Duration" then
			tweenInfo = TweenInfo.new(_Value)
			for i = 0, 9 do
				d.CanvasTweens[i] = TweenService:Create(Canvas, tweenInfo, { Position = UDim2.new(0, 0, -i, 0) })
			end
		elseif Type == "Value" then
			d.CanvasTweens[_Value]:Play()
		elseif Type == "TextSize" or Type == "Font" then
			local _Size = TextService:GetTextSize(
				"8",
				Spinner.TextSize,
				Spinner.Font,
				Vector2.new(Spinner.TextSize, Spinner.TextSize)
			)
			TweenService:Create(Frame, sizeTweenInfo, { Size = UDim2.new(0, _Size.X + 1, 0, _Size.Y + 10) }):Play()
		end
	end

	return dProxy
end

return Digit
