How to create gradual increase in movement speed when walking?

Hello! I want to make a system where when a player starts walking, they gradually increase speed and camera’s field of view, and when they stop walking, they gradually decrease speed and FOV, something along the line of how movement works in Superstar Racers. I’ve seen a few similar posts here and there, but I’ve never really understood the solutions, and they seem to show a short startup, unlike the slow and gradual increase in speed in Superstar Racers. Can somebody explain to me how I would create such a system?

Here’s one that I created that uses RunService.Heartbeat (doesn’t include FOV)

Put this on the server

local humanoid = Instance.new("Humanoid") -- replace with directory

local startspeed = 5
local maxspeed = 30
local speedincrease = 0.01
local speeddecrease = 0.01

local compare = startspeed - 1

local currentspeed = startspeed

humanoid.WalkSpeed = startspeed

game:GetService("RunService").Heartbeat:Connect(function ()
	-- gradually increase the speed
	local speed = humanoid:GetMoveVelocity().Magnitude
	if speed > compare and speed < maxspeed then
		currentspeed += speedincrease
	elseif speed > startspeed then
		currentspeed -= speeddecrease
	end
	humanoid.WalkSpeed = currentspeed
end)
1 Like

I’d recommend looking into TweenService for something like this: TweenService | Documentation - Roblox Creator Hub

I’m assuming the EasingStyle used was Sine, based on your description. Take a little look at the link I provided and you should be able to come up with something.

Both of these answers are kinda bleh and do not really do it well. Roblox has physics controllers that can be used to apply custom controllers to characters. In specific, the GroundController has an AccelerationTime property that dictates how long it would take for the controller to “ramp up” to max speed. You could modify the camera FOV based on how fast the character is presently moving.

Here’s one that I created that uses RunService.Heartbeat (doesn’t include FOV)

Put this on the server

Putting a script on the server to modify player speed will result in the player feeling incredibly weird to play as on the client, especially if you have high latency. Anything that modifies the player should be performed by the client imho

I’d recommend looking into TweenService for something like this

This does technically work but it feels like it’s not intended for something like this. Additionally, there’s not really a way to start a tween “halfway” through an animation, so decelerating before the max speed is reached would feel jank

If you want a method that does not involve a custom controller, I would manually accelerate/decelerate the player’s movement speed based on a set walkspeed/s acceleration value, and using a client sided RunService.PreSimulation event. Using the passed delta time you can multiply it by the acceleration value to make sure the acceleration is consistent between all framerates (i.e. if you’re running at 60fps, the deltatime is 1/60 seconds, thus multiplying it by your acceleration will give you an acceleration/60 increases, or a full acceleration increase every 60 frames (which would be a second in this instance))

Is a ground controller an instance? (It seems like an instance from the documentation, but I am unsure) If so, is there an already pre-existing ground controller in a player when their character is added, or do I need to manually add one on my own?

Read the physics controller article, it explains everything

I read the article but I still don’t really understand how controllers work in general, and the benefits of using them. I saw a community tutorial on using controllers, but after following the tutorial, the jumping animation seems to break and the other movement mechanics in the game (wall jumping, double jumping) also break down and don’t work anymore.