Tweening A Value

I’m trying to use TweenService to be able to simply tween a value, a number value, not a property.

For example, I would try just tweening this number value, supposedly like this:

local value = 0

TS:Create(value,TweenInfo.new(5),100):Play()

I’m aware you can create an IntValue and tween the property, but I don’t essentially want to do that. I just want to tween a direct value only. How would I do that?

If you have any suggestions or solutions, please comment them down. Thank you.

TS:Create(value,TweenInfo.new(5),{Value = 100}):Play()
You can’t tween numbers you need to use ObjectValues

You’re talking about an IntValue and changing the property. What I want to do is directly tween the variable in my script.

local variable = 0

--How do I tween the variable?

Is there really no way to tween numbers?

You can get mathematical from this.

1 Like

Can I try this though:

local values = {
    value1 = 0
}

TS:Create(values,TweenInfo.new(5),{value1 = 100})

Im technically tweening the values property…?

It’s not an object, so it wouldn’t work.

Why exactly? Using an object value should do the trick. Anyways, you could do something like this

local TweenService = game:GetService("TweenService")

local NumberValue = Instance.new("NumberValue")
local Number = 0

local Tween = TweenService:Create(NumberValue, TweenInfo.new(5), {Value = 100})
Tween:Play()

NumberValue:GetPropertyChangedSignal("Value"):Connect(function()
	Number = NumberValue.Value
end)
5 Likes

I guess I’ll just use IntValues anyway. Thanks for helping.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.