How can I gradually increase a variable?

Hi!
I am working on a hover car and I’ve run into an issue: the max speed is reached instantly. How can I make the speed gradually increase?

Code:

	local throttle = seat.ThrottleFloat
	local speed = seat.MaxSpeed * throttle
	bodyV.Velocity = Vector3.new(speed, 0, speed) * seat.CFrame.LookVector

Note: The code is in a function connected to Heartbeat.

Use a debounce to delay it:

local RunService = game:GetService("RunService")
local Debounce = false
local SecondsOfDelay = 1

RunService.Heartbeat:Connect(function()
	if not Debounce then
		delay(SecondsOfDelay, function()
			Debounce = false
		end)
		Debounce = true
		
		local throttle = seat.ThrottleFloat
		local speed = seat.MaxSpeed * throttle
		bodyV.Velocity = Vector3.new(speed, 0, speed) * seat.CFrame.LookVector
	end
end)
1 Like

Setting the BodyVelocity’s X and Z from MaxForce to something low such as 50 causes to speed to increase slower. But I think that @Sarchyx 's solution works too.