Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local function createNextbot(image: number | string, name : string)
- local bot = Instance.new("Model")
- bot.Name = name or "Nextbot"
- local controller -- find a way to make a humanoid thing
- local chaseVal = Instance.new("IntegerValue", bot)
- chaseVal.Name = "Chasing"
- local pfs = game:GetService("PathFindingService")
- local targets = {}
- task.spawn(function()
- while true do
- if not chaseVal.Value then task.wait() continue end
- --
- local nearest = nil
- for _, v in pairs(game.Players:GetPlayers()) do
- local chr = v.Character
- local hrp = chr:FindFirstChild("HumanoidRootPart")
- if hrp then
- if not nearest or (hrp.Position - controller.PrimaryPart).Magnitude < (nearest.Position - controller.PrimaryPart).Magnitude then
- nearest = hrp
- end
- end
- end
- if nearest then
- local path = pfs:CreatePath()
- path:ComputeAsync(controller.PrimaryPart.Position, nearest.Position)
- local wps = path:GetWaypoints()
- for _, w in pairs(wps) do
- controller.Humanoid:MoveTo(w.Position)
- controller.Humanoid.MoveToFinished:Wait()
- end
- end
- --
- task.wait(0.5)
- end
- end)
- bot.Parent = workspace
- return bot
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement