so i get a script from DevForum and if i try to add a move script to npc with clone cloning is working, but npc doesnt move
local player = Players.LocalPlayer
local success, friendPages = pcall(function()
return Players:GetFriendsAsync(player.UserId)
end)
if not success then
warn("There was a error while getting player's friend id!")-- remember to handle pcall errors
end
local function iterPageItems(pages)
return coroutine.wrap(function()
local pagenum = 1
while true do
for _, item in ipairs(pages:GetCurrentPage()) do
coroutine.yield(item, pagenum)
end
if pages.IsFinished then
break
end
pages:AdvanceToNextPageAsync()
pagenum += 1
end
end)
end
local userIds = {}
for item, _pageNo in iterPageItems(friendPages) do
table.insert(userIds, item.Id)
end
local randomFriend = userIds[math.random(1, #userIds)]
local newFriend = Players:CreateHumanoidModelFromUserId(randomFriend)
newFriend.Parent = game.Workspace
newFriend:FindFirstChild("HumanoidRootPart").Anchored = false
newFriend.Name = "Customer"
local hum = workspace:FindFirstChild("Customer"):FindFirstChild("Humanoid")
You said that your NPC doesn’t move, so have you coded anything to your NPC to move? Because from what I can see in the code that you posted, there is no NPC moving logic at all.
local Folder = game.Workspace.points
local hum = workspace:Waitforchild("Customer")
local loop = true
if loop then
while true do
for i, v in pairs(Folder:GetChildren()) do
hum:MoveTo(Folder:FindFirstChild(i).Position)
hum.MoveToFinished:Wait()
end
end
else
for i, v in pairs(Folder:GetChildren()) do
hum:MoveTo(Folder:FindFirstChild(i).Position)
hum.MoveToFinished:Wait()
end
end
local waypoints = workspace.points
local hum = workspace:WaitForChild("Customer")
while true do
for _, waypoint in pairs(waypoints:GetChildren()) do
hum:MoveTo(waypoint.Position)
hum.MoveToFinished:Wait()
end
end