How to make humanoid accelerate

Trying to make an npc accelerate towards player. Doesn’t accelerate.

local Humanoid = script.Parent.Zombie

Humanoid.WalkSpeed = 8

local function Moved()
	if Humanoid.MoveDirection ~= Vector3.new(0,0,0) then
		Humanoid.WalkSpeed = Humanoid.WalkSpeed*2
	else
		Humanoid.WalkSpeed = 8
	end
end

Humanoid:GetPropertyChangedSignal("MoveDirection"):Connect(Moved)

3 Likes

I think you have to define the humanoid first. It has been about 3 months since I last scripted so I cant quite remember, but you have to define the humanoid in the zombie. there are plenty of things on YouTube about humanoids.

Maybe try this:

local Humanoid = script.Parent.Zombie

Humanoid.WalkSpeed = 8

while true do
wait(0.5)
Humanoid.WalkSpeed = Humanoid.WalkSpeed + 1
end

Problem is that the speed keeps increasing when its not moving, and it also should be set back to its default speed once its stopped moving.

local Humanoid = script.Parent.Zombie

Humanoid.WalkSpeed = 8


script.Parent.Zombie.Running:Connect(function(speed)
	if speed > 0 then
		Humanoid.WalkSpeed += 2
	else
		Humanoid.WalkSpeed = 8
	end
end)
local Humanoid = script.Parent.Zombie.Humanoid -- unless you've named the humanoid "Zombie", that is.

i did, sorry should’ve made it more clear

1 Like