Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Zombie getting stuck on stairways?

Zombie NPC is getting stuck on the stairway rail.. I tried adding an invisible part on the rail and it didn't do anything. I tried changing the size a bit, but it screwed up the entire pathfinding.

local PathfindingService = game:GetService("PathfindingService")

local zomb = script.Parent
local humanoid = zomb.Humanoid
local maxDistance = 1000
-- part is the player character

function dmg(part)
	local debounce = false
	if not debounce then
		local animation = humanoid:LoadAnimation(zomb.attack)
		debounce = true
		part.Humanoid:TakeDamage(45)
		animation:Play()
		wait(1)
		debounce = false
	end
end

while wait(.2) do
	for i,plr in pairs(game.Players:GetPlayers()) do
		if plr:DistanceFromCharacter(zomb.HumanoidRootPart.Position) < maxDistance then
			player = plr
			part = plr.Character
		end
	end
	local path = PathfindingService:CreatePath()
	if part then
		path:ComputeAsync(zomb.HumanoidRootPart.Position, part.HumanoidRootPart.Position)
		local waypoints = path:GetWaypoints()
		for i,v in pairs(waypoints) do
			humanoid:MoveTo(v.Position)
			humanoid.MoveToFinished:Wait()
			if player:DistanceFromCharacter(zomb.HumanoidRootPart.Position) < 5 then
				dmg(part)
			end
		end
	end
	if humanoid.Health <= 0 then
		script:Destroy()
	end
end

screenshot https://lh3.googleusercontent.com/-dRqlF7Q82Fc/Xv1k2uhr4QI/AAAAAAAAFZ4/Q5Lzr1zsKy4vn4ED-k0WyRFkLhIiwf6RgCK8BGAsYHg/s0/2020-07-01.png

1 answer

You forgot to make the zombie jump whenever the path includes jumping, it's very important.

	if v.Action == Enum.PathWaypointAction.Jump then
				humanoid.Jump = true
			end

Include this in the for i , v in pairs (waypoint) loop.

3 comments

0

It did work, but occasionally the zombie stops for 8 seconds (the timeout) and then continues. Also, zombies still get stuck sometimes.

0

it's just roblox's dodge shit pathfinding

0

Ah, ok.

This discussion is preserved as it was. New answers, comments, and votes are closed.