Creating slow acceleration with walkspeed

Hello there! As the title says, I’m trying to create slow acceleration with walkspeed. The way I’m currently doing this is by using Humanoid.Running, then increasing the walkspeed by 1 every time until the max speed is reached. However it does not have the desired effect as I would like it to, because it accelerates too fast, and using wait() won’t help since it’s an event. How do I make the humanoid very slowly accelerate? Sorry if I came out confusing.

2 Likes

Have you tried to use TweenService?

1 Like

Tween Humanoid.WalkSpeed:

local player = game.Players.LocalPlayer
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
humanoid.WalkSpeed = 5
local tweenservice = game:GetService("TweenService")
local tweeninfo = TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.In, 0, false, 0)
local tween = tweenservice:Create(humanoid, tweeninfo, {["WalkSpeed"] = 20})
tween:Play()
1 Like

This might work:

local player = game.Players.LocalPlayer
local character = player.Character:Wait()
local humanoid = character:WaitForChild('Humanoid')
humanoid.WalkSpeed = --Starting walkspeeed here
repeat
   task.wait(--How long it should take for speed to increase)
   humanoid.WalkSpeed += --How much speed should increase
until humanoid.WalkSpeed >= --Ending walkspeed (The ">= Is just incase the walkspeed goes higher than what you want")

if you need to reset the speed to 5 each time the player stop you can make it like this:

local TweenService = game:GetService("TweenService")
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Tween



function HandleWalkSpeed(Char)
	local Humanoid = Char:WaitForChild("Humanoid")
	Humanoid.WalkSpeed = 5
	Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(function()
		if Humanoid.MoveDirection == Vector3.new(0,0,0) then
			Humanoid.WalkSpeed = 5
			if Tween then
				Tween:Cancel()
			end
			Tween = nil
		elseif not Tween then
			Tween = TweenService:Create(Humanoid,TweenInfo.new(10, Enum.EasingStyle.Sine, Enum.EasingDirection.In),{WalkSpeed = 20})
			Tween:Play()
		end
	end)
end

if Character then
	HandleWalkSpeed(Character)
end

Player.CharacterAdded:Connect(function(Character)
	HandleWalkSpeed(Character)
end)

1 Like

That would probably work. I didn’t know TweenService was even possible with WalkSpeed, thank you.

1 Like

Its possible with any property in roblox even boolean one but since we cannot tween the true smoothly to false or opposite, TweenService just change them to directly after the tween reach the half.

1 Like