uhhhh question up there.





local humanoidrootpart = script.Parent:FindFirstChild("HumanoidRootPart")
local human = script.Parent:FindFirstChild("Humanoid")


function JUMP()
	human.Jump = true
end

function findTarget()
	local distant = 200
	local target = nil
	for i,v in pairs(workspace:GetChildren()) do
		local humanoid = v:FindFirstChild("Humanoid")
		local head = v:FindFirstChild("Head")
		if humanoid and head and v.Name ~= script.Parent.Name then
			if (head.Position - humanoidrootpart.Position).magnitude < distant and humanoid.Health > 0 then
				distant = (head.Position - humanoidrootpart.Position).magnitude
				target = head
			end
		end
	end
	return target
end
while wait(0) do
	local head = findTarget()
	if head then
		local ray = Ray.new(humanoidrootpart.Position, (head.Position - humanoidrootpart.Position).Unit * 200)
		local hit,position = workspace:FindPartOnRayWithIgnoreList(ray,{script.Parent})
		if hit then
			hit:IsDescendantOf(head.Parent)
				human:MoveTo(head.Position)
		else
			human:MoveTo(head.Position)
			wait(.4)
			local path = game:GetService("PathfindingService"):FindPathAsync(humanoidrootpart.Position,head.Position)
			local points = path:GetWayPoints()
			if path.Status == Enum.PathStatus.Success then
			for i,v in pairs(points) do
				human:MoveTo(v.Position)
				wait(2)
				
				if v.Action == Enum.PathWaypointAction.Jump then
					JUMP()
				end
				if (points[#points].Position - head.Position).magnitude > 15 then
					break
				end
			end
			else
				human:MoveTo(head.Position)
			end
		end
	end
end



4 comments

0

pls help me ;-;

0

I'm not good at this stuff...

0

I had the same issue, add this. It should work! repeat wait() if v.Action == Enum.PathWaypointAction,Jump then JUMP() end human:MoveTo(v.Position) until (humanoidrootpart.Position - v.Position).Magnitude <= 5

0

vadim blyat