How can i change a value in a predetermined speed?

Hello, I’m looking to change a value relative to a predefined speed. On the script below, the value changes according to a time, so whether I change the value by 1 or 10 units, it will take 10 seconds.
I’d like it to take 10 seconds to change the value by 10 units, but 1 second if I change it by just one unit (for exemple).

local runS = game:GetService("RunService")
local Count = 1
local Target = 10
local Duration = 10
local Timing = (Target - Count)/Duration

local Tick = workspace.DistributedGameTime

while true do
	if workspace.DistributedGameTime - Tick > Duration then break end    
	Count += Timing * runS.Heartbeat:Wait()    
	print(Count)
end

Any help is highly apprecied. Thank you :slight_smile:

local function incrementFunction(increment_value)
  for i = 1,increment_value do
    wait(1)
    value += 1
  end
end

This’ll make it take 10s to add 10, 100 to add 100, etc

I’m more looking for a way without any break (no waiting time inside the loop)

I know it’s possible with some maths but i have no clue how to do it :confused:

Use task.spawn() for that task | Documentation - Roblox Creator Hub

That wouldn’t be the best way of doing it