How do you make acceleration

Hi, I’m wondering how i can make acceleration code in Roblox I tried searching everywhere but i couldn’t find de answer how to make acceleration code. :thinking:

6 Likes

its easiest to do with loops and I think its most efficient with repeat until loops like

repeat wait(0.1)--change wait() to whenever the speed increases
acceleration += 1 --change depending on speed
until acceleration = 200 --change to the max acceleration
2 Likes

It’s good but if you accelerate how do you decelerate. :face_with_diagonal_mouth:

4 Likes
repeat wait(0.05)
acceleration -= 1
until acceleration = 0
5 Likes

Instead of using a repeating loop, you can just use a VectorForce. Set the direction of the force to go in the direction that you want, and you’ll have a smooth acceleration (depending on the mass of the object, you may need to increase the total force a bit)

4 Likes

But how can I use it on the default Roblox movement?

2 Likes

Do you mean how to make the player accelerate instead of instantly going fast when moving (such as in those clicker running game thingies)?

2 Likes

do you mean walking speed or something else

2 Likes

Roblox default movement has no acceleration it goes like 1 - 16 in a second so I tried making a code to make it accelerate but it didn’t work.

3 Likes
repeat wait(0.1)
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed += 0.1
until game.Players.LocalPlayer.Character:WaitForChild("Humanoid").WalkSpeed == 32
3 Likes

oh sorry I read it wrong heres the corrected script

game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Walkspeed = 1
repeat wait(0.1)
game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Walkspeed += 1
until game.Players.LocalPlayer.Character:WaitForChild("Humanoid").Walkspeed == 16
3 Likes

I think this is right idea how to make it. but I think I’m gone try using vector force and experiment with it. Thank for the help :slightly_smiling_face:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.