Hello, I am trying to make a thing where the player creates paths and an NPC follows them. The NPC is not following them.
Spawning the paths–
local point1pos = game:GetService("ReplicatedStorage").Point1Position.Value
local pointnum = game:GetService("ReplicatedStorage").PointNumber.Value
local point = game:GetService("ReplicatedStorage").Point
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local mouse = player:GetMouse()
local mousepos = mouse.Hit.Position
mouse.Button1Down:Connect(function()
point1pos = mousepos
mousepos = mouse.Hit.Position
local part = point:Clone()
part.Parent = workspace.Folder
part.Position = mousepos
part.Name = ("Point"..pointnum)
pointnum += 1
end)
Spawning the NPC–
local point1pos = game:GetService("ReplicatedStorage").Point1Position.Value
local button = script.Parent
button.Activated:Connect(function()
local NPC = game:GetService("ReplicatedStorage").Bob:Clone()
NPC.Parent = workspace
wait(.5)
NPC:MoveTo(workspace.Folder:WaitForChild("Point1").Position)
end)
NPC pathfind–
local ps = game:GetService("PathfindingService")
local humanoid = script.Parent.Parent.Humanoid
wait(1)
for i, v in pairs(workspace.Folder) do
humanoid:MoveTo(v.CFrame)
wait(1)
end
Somebody please help.