Animation on patrol script

hello i have this pathfind script down below but when i use like classic chasing script animation works like intended video nr.1 and when its patrol one they glitch like that and other scripts that are detecting humanoid running start glitching out , did someone faced / know how to fix this issue?

local Bot = script.Parent.Parent
local Humanoid = Bot.Humanoid
local count = 20
local walking = false
local tpcount = 0
while wait() do
	local success, err = pcall(function()
		Bot.PrimaryPart:SetNetworkOwner(nil)
	end)
	if success then break
	else
		print("NewBot:", err)
	end
end

local function getPath(Point)
	local PathfindingService = game:GetService("PathfindingService")

	local pathParams = {
		["AgentHeight"] = 5,
		["AgentRadius"] = 2,
		["AgentCanJump"] = true
	}

	local path = PathfindingService:CreatePath(pathParams)

	path:ComputeAsync(Bot.HumanoidRootPart.Position, Point.Position)

	return path
end

local function MoveTo(WayPoint)
	
end
local function walkTo(Point)

	local path = getPath(Point)

	if path.Status == Enum.PathStatus.Success then
		for index, waypoint in pairs(path:GetWaypoints()) do
			if waypoint and waypoint.Action == Enum.PathWaypointAction.Walk then
				Humanoid.Jump = false
				Humanoid:MoveTo(waypoint.Position)
				Humanoid.MoveToFinished:Wait(0.1)



			elseif  waypoint and waypoint.Action == Enum.PathWaypointAction.Jump then
				Humanoid.Jump = true

			end
			walking = false
		end
	else
		Humanoid:MoveTo(Point.Position - (Bot.HumanoidRootPart.CFrame.LookVector * 10))
		walking = false
	end
end

local function TeleportTo(Point)
	tpcount = 0
	Point.Effects:FindFirstChild("Fire").Enabled = true
	wait(1)
	Bot.HumanoidRootPart.Teleport:Play()

	wait(1)
	
	Bot:SetPrimaryPartCFrame(Point.CFrame)
	Bot.HumanoidRootPart.Teleport:Play()

	wait(1)
	Point.Effects:FindFirstChild("Fire").Enabled = false
	walking = false


end

function PatrolPoints()
	local waypoints = game.Workspace.Map.BotWaypoints:GetChildren()
	local randomNum = math.random(1, #waypoints)
		walkTo(waypoints[randomNum])

	

	
	walking = false

end

while true do
	wait(0.25)
	if walking == false then
		PatrolPoints()
	end
end


just remaiding :grinning: pls help me i dont know what to do

Can you fix your videos? They’re not playing. If you’re recording with roblox, convert the file to an mp4.

ok there



they are im sorry , video nr.1 is not really good but 2nd shows that anims dont act correctly , this happens with every animation on every bot with this script , any help would be apriceated

. this script is bad i know but when i tried reamking it here `local Dummy = script.Parent.Parent
local Humanoid = Dummy.Humanoid
local walking = false
local function FindPath(Point)
local PathfindingService = game:GetService(“PathfindingService”)

local pathParams = {
	["AgentHeight"] = 5,
	["AgentRadius"] = 3,
	["AgentCanJump"] = false
}

local path = PathfindingService:CreatePath(pathParams)

path:ComputeAsync(Dummy.HumanoidRootPart.Position, Point.Position)

return path

end

local function walkTo(Point)

local path = FindPath(Point)

if path.Status == Enum.PathStatus.Success then
	for index, waypoint in pairs(path:GetWaypoints()) do
		Humanoid:MoveTo(waypoint.Position)
		Humanoid.MoveToFinished:Wait()
	end
	walking = false

else
	walking = false

end

end
local function FindTarget ()
local points = game.Workspace.Map.BotWaypoints:GetChildren()
local randumnum = math.random(1,#points)
local point = points[randumnum]
walking = true
walkTo(point)

end
while true do
wait(0.25)
if walking == false then

	FindTarget()

end

end` then every waypoint in path bot would make a break in around 0,1 sec that was even worse!

PLS HELP I TRIED FIXING IT BUT IT DIDN’T WORK. `local Bot = script.Parent.Parent
local Humanoid = Bot.Humanoid

local function getPath(Point)
local PathfindingService = game:GetService(“PathfindingService”)

local pathParams = {
	["AgentHeight"] = 5,
	["AgentRadius"] = 2,
	["AgentCanJump"] = false
}

local path = PathfindingService:CreatePath(pathParams)


return path

end
function Patrol()
local waypoints = game.Workspace.Map.BotWaypoints:GetChildren()
local randomNum = math.random(1, #waypoints)
Actual(waypoints[randomNum])
end
function Actual(Point)
local path = getPath(Point)
path:ComputeAsync(Bot.HumanoidRootPart.Position, Point.Position)
local waypoints = path:GetWaypoints()
while #waypoints > 0 do
wait(0.1)
path:ComputeAsync(Bot.HumanoidRootPart.Position, Point.Position)
waypoints = path:GetWaypoints()
Humanoid:MoveTo(waypoints[1].Position)
end

end
while true do
wait(0.24)
Patrol()
end`

i fixed issue by my self turns out it was foult of movetofinished:wait soo i made it like in chase player script wich will also make bot get stuck less often becose path will be refreshed

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