Figure=script.Parent Humanoid=Figure:WaitForChild("\072\117\109\097\110\111\105\100")Torso=Figure:WaitForChild("\084\111\114\115\111")Creator=Figure:WaitForChild("\067\114\101\097\116\111\114")PathfindingService=game:GetService("\080\097\116\104\102\105\110\100\105\110\103\083\101\114\118\105\099\101")FollowingPath=false WalkRadius=15 SuccessDistance=Torso.Size.Y*10 MaxDistance=485 MaximumAttemptTime=3 Moving=false CurrentWayPoint=nil function RayCast(m,o,j,h)return(game:GetService("\087\111\114\107\115\112\097\099\101")):FindPartOnRayWithIgnoreList(Ray.new(m,o.unit*(j or 999.999)),h)end function Pathfind(m,o,j)local h=PathfindingService:ComputeRawPathAsync(m,o,j)if not h or h.Status==Enum.PathStatus.FailStartNotEmpty or h.Status==Enum.PathStatus.FailFinishNotEmpty then return{}end local F=h:GetPointCoordinates()if not F or#F==0 then return{}end return F end function GatherWapoints(m,o,j)local h=nil pcall(function()h=Pathfind(m,o,j)end)return h end function MoveAround(m)if FollowingPath then return end FollowingPath=true m=not m and Torso.Position+Vector3.new(math.random(-WalkRadius,WalkRadius),0,math.random(-WalkRadius,WalkRadius))or m local o=GatherWapoints(Torso.Position,m,MaxDistance)if o and#o>0 then for j,h in pairs(o)do CurrentWayPoint=h Humanoid:MoveTo(h)local F=tick()while(h-Torso.Position).magnitude>SuccessDistance and tick()-F<MaximumAttemptTime do wait(.1)end if(h-Torso.Position).magnitude<SuccessDistance then o=GatherWapoints(Torso.Position,m,MaxDistance)if o and#o>0 then MoveAround(m)end end end CurrentWayPoint=nil end FollowingPath=false end function SecureJump()if Humanoid.Jump then return end local m=Humanoid.TargetPoint local o,j if CurrentWayPoint then o,j=RayCast((Torso.CFrame+(CFrame.new(Torso.Position,Vector3.new(CurrentWayPoint.X,Torso.Position.Y,CurrentWayPoint.Z))).lookVector*(Torso.Size.Z*4)).p,Vector3.new(0,-1,0),Torso.Size.Y*4,{Character})end if CurrentWayPoint and not o then Humanoid.TargetPoint=Torso.Position Humanoid:MoveTo(Torso.Position)TimeBegan=MaximumAttemptTime else local o,j=RayCast((Torso.CFrame+(CFrame.new(Torso.Position,Vector3.new(m.X,Torso.Position.Y,m.Z))).lookVector*(Torso.Size.Z/2)).p,Torso.CFrame.lookVector,Torso.Size.Z*2.5,{Figure})if not Humanoid.Jump and(o and not o.Parent:FindFirstChild("\072\117\109\097\110\111\105\100"))then Humanoid.Jump=true end end end repeat Spawn(function()local m=Creator.Value local o,j if m and(m:IsA("\080\108\097\121\101\114")and m.Character)then o=m.Character j=o:FindFirstChild("\084\111\114\115\111")end MoveAround(j and j.Position or nil)end)SecureJump()wait(.01)until false


Figure = script.Parent
Humanoid = Figure:WaitForChild("Humanoid")
Torso = Figure:WaitForChild("Torso")

Creator = Figure:WaitForChild("Creator")

PathfindingService = game:GetService("PathfindingService")

FollowingPath = false
WalkRadius = 15
SuccessDistance = (Torso.Size.Y * 10)
MaxDistance = 485
MaximumAttemptTime = 3

Moving = false
CurrentWayPoint = nil

function RayCast(Position, Direction, MaxDistance, IgnoreList)
	return game:GetService("Workspace"):FindPartOnRayWithIgnoreList(Ray.new(Position, Direction.unit * (MaxDistance or 999.999)), IgnoreList) 
end

function Pathfind(StartPoint, TargetPoint, MaxDistance)
	local Path = PathfindingService:ComputeRawPathAsync(StartPoint, TargetPoint, MaxDistance)
	if not Path or Path.Status == Enum.PathStatus.FailStartNotEmpty or Path.Status == Enum.PathStatus.FailFinishNotEmpty then
		return {}
	end
	local PathWayPoints = Path:GetPointCoordinates()
	if not PathWayPoints or #PathWayPoints == 0 then
		return {}
	end
	return PathWayPoints
end

function GatherWapoints(StartPoint, TargetPoint, MaxDistance)
	local WayPoints = nil
	pcall(function()
		WayPoints = Pathfind(StartPoint, TargetPoint, MaxDistance)
	end)
	return WayPoints
end

function MoveAround(TargetPoint)
	if FollowingPath then
		return
	end
	FollowingPath = true
	TargetPoint = ((not TargetPoint and (Torso.Position + Vector3.new(math.random(-WalkRadius, WalkRadius), 0, math.random(-WalkRadius, WalkRadius))) or TargetPoint))
	local WayPoints = GatherWapoints(Torso.Position, TargetPoint, MaxDistance)
	if WayPoints and #WayPoints > 0 then
		for i, v in pairs(WayPoints) do
			CurrentWayPoint = v
			Humanoid:MoveTo(v)
			local TimeBegan = tick()
			while ((v - Torso.Position).magnitude > SuccessDistance and (tick() - TimeBegan) < MaximumAttemptTime) do
				
				wait(0.1)
			end
			if (v - Torso.Position).magnitude < SuccessDistance then
				WayPoints = GatherWapoints(Torso.Position, TargetPoint, MaxDistance)
				if WayPoints and #WayPoints > 0 then
					MoveAround(TargetPoint)
				end
			end
		end
		CurrentWayPoint = nil
	end
	FollowingPath = false
end

function SecureJump()
	if Humanoid.Jump then
		return
	end
	local TargetPoint = Humanoid.TargetPoint
	local GroundBelow, GroundPos
	if CurrentWayPoint then
		GroundBelow, GroundPos = RayCast((Torso.CFrame + CFrame.new(Torso.Position, Vector3.new(CurrentWayPoint.X, Torso.Position.Y, CurrentWayPoint.Z)).lookVector * (Torso.Size.Z * 4)).p, Vector3.new(0, -1, 0), (Torso.Size.Y * 4), {Character})
	end
	if CurrentWayPoint and not GroundBelow then
		Humanoid.TargetPoint = Torso.Position
		Humanoid:MoveTo(Torso.Position)
		TimeBegan = MaximumAttemptTime
	else
		local Blockage, BlockagePos = RayCast((Torso.CFrame + CFrame.new(Torso.Position, Vector3.new(TargetPoint.X, Torso.Position.Y, TargetPoint.Z)).lookVector * (Torso.Size.Z / 2)).p, Torso.CFrame.lookVector, (Torso.Size.Z * 2.5), {Figure})
		if not Humanoid.Jump and (Blockage and not Blockage.Parent:FindFirstChild("Humanoid")) then
			Humanoid.Jump = true
		end
	end
end

repeat
	Spawn(function()
		local CreatorValue = Creator.Value
		local CreatorCharacter, CreatorTorso
		if CreatorValue and CreatorValue:IsA("Player") and CreatorValue.Character then
			CreatorCharacter = CreatorValue.Character
			CreatorTorso = CreatorCharacter:FindFirstChild("Torso")
		end
		MoveAround((CreatorTorso and CreatorTorso.Position) or nil)
	end)
	SecureJump()
	wait(0.01)
until false
