Make a value smoothly change

  1. What do you want to achieve?
    Hello, i have a value and i want to to change smoothly.

  2. What is the issue?
    I don’t know how to do it.

  3. What solutions have you tried so far?
    I looked on forums and i didn’t find anything.

2 Likes

What type of value are you wanting to change

I want to change a NumberValue

You can use TweenService, No doubts, it can change almost every value!
TweenService Api Link

TweenService also come with the benefit of easing types. So, you could smoothly (and not linearly) make a part more reflective or something.

As told above check TweenService | Roblox Creator Documentation it’s a very useful tool for smooth animations.

local TweenService = game:GetService("TweenService") 

local NumberValue = script.NumberValue --value path

local tween_time = 5 --time between each tween
--check https://developer.roblox.com/en-us/api-reference/enum/EasingStyle
local easing = Enum.EasingStyle.Linear 
local direction = Enum.EasingDirection.InOut 
local repeats = 0 
local reverses = false 
local tween_delay = 0 --delay between each tween

local Info = TweenInfo.new(tween_time, easing, direction, repeats, reverses, tween_delay)
local Goal = 50 --where you want the value to go 

local Properties = {
	Value = Goal 
}

local Tween = TweenService:Create(NumberValue, Info, Properties) 
Tween:Play() --play the tween 
--Tween:Stop() --stop the tween

tweenservice. One word. Tweenservice.