#How would I be able to tween a number variable

1 messages · Page 1 of 1 (latest)

glad yarrow
#

Hii scripters, im an experienced scripter and I was wondering what would be the best way to tween a number, and I'm quite surprised to see that this is a topic that few developers are familiar with because we use tweening alot for our game but we've never thought of doing it on numbers.

I know that it's possible by creating a NumberValue instance and tween the value inside, but I don't like dealing with BaseValue Instances, I thought of making a function creates a numbervalue instance, tweens it and return the value, and then delete it after the tweening is completed.

TweenNumber(value,duration,function(v)
  number = v
end)```
But imo, that seems kind of unoptimized if we compare this to modules that reproduces this mathematically, thing is I searched it up on Google and couldn't find anything regarding it.

TL;DR: Title.
wide oasis
#

why do you want to tween a number

#

like what is the use case

#

@glad yarrow

glad yarrow
# wide oasis <@793109785024790539>

Oh I'm sorry for being so late, In my use case right now I want to ease exponentially the camera offset when I crouch for example, (as I am writing this I realized it would rather be about vector3s, but either way it would still face the same problem)

amber anchor
#

i dont understand

#

why are you easing the camera offset

#

also you cannot tween numbers

#

you can tween numbervalues

glad yarrow
amber anchor
#

but numbers, no

glad yarrow
#

Thats what I've explicitly said on my post.

#

I'm aware of that

amber anchor
#

so you tween the number, return it and delete it?

glad yarrow
#

That would be my idea, but I do not really like it because I'm pretty sure theres some better ways like getting a module that does it mathematically for you (instead of relying on a numbervalue instance)

amber anchor
#

then use a module

glad yarrow
#

thing is I searched it up on Google and couldn't find anything regarding it.

amber anchor
#

regarding the module?

glad yarrow
#

Yup

amber anchor
#

what explicitly did you search

#

and what would be the point of searching

pearl temple
#

I found a post that should help you

#

There's some comments in there that solve the problem

glad yarrow
#

oh interesting

glad yarrow
#

Even though its not that much of a big deal

#

like its a non-issue

amber anchor
#

have you tried lerping the number perchance

glad yarrow
#

Of course, but im not interested with lerping as you see, as I really want to ease with different easing styles like how TweenService work.

#

Anyways

#

Thanks for the infos guys, im just gonna close this post.