I have problem with PathFindingSerive.I tried to move NPC to random waypoint but it throws an error
17:41:22.162 Unable to cast double to Vector3 - Server - Script:10
I cant find any solution that related to my problems
this is the scripts:
local NPC = script.Parent
local humanoid = NPC.Humanoid
local way = game.Workspace.WaypointPlayer:GetChildren()
local point = math.random(1 , #way)
local PathService = game:GetService("PathfindingService")
local path = PathService:CreatePath()
path:ComputeAsync(NPC.UpperTorso.Position, point)
local waypoints = path:GetWaypoints()
for i , v in pairs(waypoints)do
humanoid:MoveTo(v.Position)
humanoid.MoveToFinished:wait(1)
humanoid:MoveTo(v.Position)
end
:ComputeAsync() takes 2 parameters, a starting position (Vector3) and an end position (Vector3). You provided a Vector3 for the first parameter but ‘point’ is a number determined by math.random() (hence the actual error you’re getting).
I’m assuming ‘game.Workspace.WaypointPlayer’ contains some sort of instances with a position property (I’m not sure what objects they are so I can’t guarantee). In the example of if the children of WaypointPlayer are parts, then you would replace: