Add Acceleration to the Player's Speed?


local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded():Wait()
local Humanoid = Character.Humanoid
local Root = Character.HumanoidRootPart

local BaseWaitTimer = .4
local MinSpeed = 12
local MaxSpeed = 40


local WaitTimer = BaseWaitTimer
Humanoid.WalkSpeed = MinSpeed

function Start()
	
	local MoveDirDB = false
	
	local function Accelerate()
		if Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) and MoveDirDB == false and Humanoid.WalkSpeed < MaxSpeed then
			MoveDirDB = true
			while Humanoid.MoveDirection ~= Vector3.new(0, 0, 0) and Humanoid.WalkSpeed < MaxSpeed do
				Humanoid.WalkSpeed = Humanoid.WalkSpeed + 1
				
				wait(WaitTimer)
				WaitTimer = WaitTimer / 1.1
			end
			MoveDirDB = false
		elseif Humanoid.MoveDirection == Vector3.new(0, 0, 0) then
			WaitTimer = BaseWaitTimer
			Humanoid.WalkSpeed = MinSpeed			
		end
	end
	
	Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(Accelerate)
end

Start()

this is an Acceleration local script I made, Adding Acceleration is rather easy but Deceleration is an other matter and I can’t really think of a good way to do it currently

37 Likes