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

Am I able to tween a number value in a script?

I am wondering if you can use tweenservice to tween a number in a script

local number = 1

game:GetService:("TweenService"):Create(number, TweenInfo.new(1), {0})

1 answer

✓ Accepted answer

This should do it:

local tweenedNumber = 0
function tweenNumber(current, goal, totalSteps, runFunction)
	for i = 1,totalSteps,goal/totalSteps do
		tweenedNumber = i
		if runFunction then
			runFunction(i)
		end
	end
end

--to get the tween, use tweenNumber.
--example:
tweenNumber(0,30,30, function(x) print(x) end)
--prints out 1,2,3,4,5..30

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