Can someone please help with the error below, I am trying to use EZ Pathfinding but it keeps saying my Vector3 is not valid. I am trying to specify the location of the NPC to move to.
Error Position is not a valid member of Vector3
wait(5)
local mod = require(WorkSpace:FindFirstChild(“PathfindingV5”))
local goalPos = workspace.Goal
local npc = script.Parent
local path = mod.new (npc, **Vector3.new(goalPos.Position.X,goalPos.Position.Y,goalPos.Position.Y))**
path.Move()
I’m assuming the Goal in workspace is a model. You can’t get a position from a model, it must be a part. so you should put a part in the model or use a part from the model and get it’s position instead
The code below fails with the same error “Position is not a valid member of Vector3”
local path = mod.new (npc, Vector3.new(goalPos))
goalPos is just a basic part in the workspace I want the NPC to travel to.
EZ Pathfinder called function
function Path.new(Target, Endpoint)
--@ Creates a new path.
local params = {AgentRadius = AgentRadius1, AgentHeight = AgentHeight1, AgentCanJump = AgentCanJump1}
local path = PathFindingService:CreatePath(params)
local self = {
["Target"] = Target;
["Time"] = Path.CalculateTimeRaw(Target, Endpoint);
["Endpoint"] = Endpoint;
["CurrentWaypointIndex"] = 1;
["Walkspeed"] = 16;
["JumpPower"] = 100;
};
if Target then
self["Path"] = path
if Target:FindFirstChildOfClass("Humanoid") then
--@ Target is a rig
self["Humanoid"] = Target:FindFirstChildOfClass("Humanoid")
local RootPart = Target:WaitForChild("HumanoidRootPart")
-- FAILS HERE
if typeof(Endpoint) == "Vector3" or typeof(Endpoint) == "Instance" then
path:ComputeAsync(RootPart.Position, Endpoint.Position)
path.Blocked:Connect(OnPathBlocked, Target, Endpoint, self["CurrentWaypointIndex"])
self["Humanoid"].MoveToFinished:Connect(function(status)
onWaypointReached(status, self, Target, self["CurrentWaypointIndex"], path:GetWaypoints())
end)
end
else
--@ Target class is not a rig
if typeof(Endpoint) == "Vector3" or typeof(Endpoint) == "Instance" then
path:ComputeAsync(Target.Position, Endpoint.Position)
end
self["TweenPause"] = false
self["TweenStop"] = false
end
end
return setmetatable(self, Path)
end