I want bots in my game to move to random places. I tried to do it by placing parts all over the place and scripting this. But it didn't work. Please help, thank you! <3
local pathfindingService = game:GetService("PathfindingService")
local humanoid = script.Parent:WaitForChild("Humanoid")
local torso = script.Parent:WaitForChild("Torso")
local startingPoint = torso.Position
local endingPoints = game.Workspace.EndParts:GetChildren()
local endingPoint = endingPoints[math.random(1, endingPoints)]
local path = pathfindingService:CreatePath()
path:ComputeAsync(torso.Position, endingPoint)
while true do
humanoid:MoveTo(endingPoint)
wait(1)
end

1 comment
THANK YOU VERY MUCH! YOU SAVED MY LIFE!