So im trying to make npc's walk to certain points, but its not working, and its just making them all walk to the same spot, any help?

> cooldown = false
> 
> function sit(v)
> 	wait()
> 	local seat = game.Workspace:WaitForChild(v:WaitForChild("SeatPart").Value)
> 	seat:Sit(v:WaitForChild("Humanoid"))
> 	wait(5)
> 	cooldown = false
> end
> 
> while wait() do
> 	local number = math.random(1, 2)
> 	if number == 1 then
> 		local v = game.ReplicatedStorage:FindFirstChild("FoodNPCS"):FindFirstChild("FoodNPCL")
>             if cooldown == false then
> 			cooldown = true
> 			v.Parent = game.Workspace
> 			local position = Vector3.new(game.Workspace:WaitForChild(v:WaitForChild("SeatPart").Value).Position)
> 			print(game.Workspace:WaitForChild(v:WaitForChild("SeatPart").Value).Position)
> 			local humanoid = v:WaitForChild("Humanoid") --parented to character
> 			humanoid.WalkToPart = nil -- Work around here!
> 			humanoid:MoveTo(position) --call MoveTo() on humanoid
> 			humanoid.MoveToFinished:Connect(function(reached)
> 		    sit(v)
> 			end)			
> 		else
> 			if number == 2 then
> 			local v = game.ReplicatedStorage:FindFirstChild("FoodNPCS"):FindFirstChild("FoodNPCR")
> 			if cooldown == false then
> 				cooldown = true
> 				v.Parent = game.Workspace
> 				local position = Vector3.new(game.Workspace:WaitForChild(v:WaitForChild("SeatPart").Value).Position)
> 					local humanoid = v:WaitForChild("Humanoid") --parented to character
> 					humanoid.WalkToPart = nil -- Work around here!
> 				humanoid:MoveTo(position) --call MoveTo() on humanoid
> 				humanoid.MoveToFinished:Connect(function(reached)
> 					sit(v)
> 				end)			
> 			end
> 		end
> 		end
> 	end
> 	end

2 comments

0

why do u have those > signs?

0

What do you mean?