Honestly this script looks like a hair comb with spaghetti spilled on it. Any way to make this more neat?
FYI: this is a script to make a rolling counter like EarthBound’s rolling hp meter
Code:
zero = UDim2.new(0, 0, 0, -42 * 0)
one = UDim2.new(0, 0, 0, (-42 * 1))
two = UDim2.new(0, 0, 0, (-42 * 2))
three = UDim2.new(0, 0, 0, (-42 * 3))
four = UDim2.new(0, 0, 0, (-42 * 4))
five = UDim2.new(0, 0, 0, (-42 * 5))
six = UDim2.new(0, 0, 0, (-42 * 6))
seven = UDim2.new(0, 0, 0, (-42 * 7))
eight = UDim2.new(0, 0, 0, (-42 * 8))
nine = UDim2.new(0, 0, 0, (-42 * 9))
zer = UDim2.new(0, 0, 0, (-42 * 10))
e1 = Enum.EasingDirection.In
e2 = Enum.EasingStyle.Quad
local function setones(number, speed)
if number == 1 then
script.Parent.Frame:TweenPosition(one,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 2 then
script.Parent.Frame:TweenPosition(two,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 3 then
script.Parent.Frame:TweenPosition(three,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 4 then
script.Parent.Frame:TweenPosition(four,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 5 then
script.Parent.Frame:TweenPosition(five,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 6 then
script.Parent.Frame:TweenPosition(six,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 7 then
script.Parent.Frame:TweenPosition(seven,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 8 then
script.Parent.Frame:TweenPosition(eight,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 9 then
script.Parent.Frame:TweenPosition(nine,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 0 then
script.Parent.Frame:TweenPosition(zero,e1,e2,speed,true)
wait(speed + 0.1)
elseif number == 10 then
script.Parent.Frame:TweenPosition(zer,e1,e2,speed,true)
wait(speed + 0.1)
script.Parent.Frame.Position = zero
end
end
while true do
wait()
for i = 0, 10 do
setones(i, 0.2)
end
end