Acceleration: local NPC = script.Parent local h = NPC.Humanoid local hrp = NPC:WaitForChild("HumanoidRootPart") local bf = Instance.new("BodyForce", hrp) h:GetPropertyChangedSignal("WalkToPoint"):Connect(function() if hrp.Velocity.Magnitude > 30 then bf.Force = (h.WalkToPoint - hrp.Position).Unit * 400 * Vector3.new(1, 0, 1) else bf.Force = (h.WalkToPoint - hrp.Position).Unit * math.random(10000, 12000) * Vector3.new(1, 0, 1) end if h.WalkToPoint == nil then bf.Force = Vector3.new(0, 0, 0) end end) Pathfind: local PFS = game:GetService("PathfindingService") local debris = game:GetService("Debris") local RunService = game:GetService("RunService") local NPC = script.Parent local h = NPC.Humanoid local folder = Instance.new('Folder', workspace) local n = math.random(0, 1000) local function foldering() if not workspace:FindFirstChild("Waypoints_" .. n) then folder.Name = "Waypoints_" .. n NPC.FolderID.Value = n -- ID to know which folder belongs to who else n = math.random(0, 1000) foldering() end end foldering() local function findAndGoTo(destination) local path = PFS:FindPathAsync(NPC.HumanoidRootPart.Position, destination.Position) if path.Status == Enum.PathStatus.Success then folder:ClearAllChildren() for i,v in ipairs(path:GetWaypoints()) do local part = Instance.new("Part", folder) part.Name = "Waypoint_" .. i part.Size = Vector3.new(1,1,1) part.Position = v.Position part.Anchored = true part.BrickColor = BrickColor.new("Really red") part.Material = Enum.Material.Neon part.CanCollide = false part.Transparency = 1 end for i,v in ipairs(path:GetWaypoints()) do h:MoveTo(v.Position) h.MoveToFinished:Wait() if v.Action == Enum.PathWaypointAction.Jump then h.JumpPower = 100 + math.abs(destination.Position.Y - NPC.HumanoidRootPart.Position.Y) h.Jump = true end end else h:MoveTo(destination.Position) if destination.Position.Y - NPC.HumanoidRootPart.Position.Y then if math.sqrt(math.pow((destination.Position.X-NPC.HumanoidRootPart.Position.X), 2) + math.pow((destination.Position.Z-NPC.HumanoidRootPart.Position.Z), 2))
@kok70614 күн бұрын
Ну спасибо, а то постоянно мне попадаются видео где говорят что надо использовать тулбокс. изменено: у меня не сработало, дизлайк. изменено снова: теперь работает, лайк.