Unable to cast PathWaypoint to Vector3

Why am I getting this error? I have used this method everytime.
Unable to cast PathWaypoint to Vector3

SCRIPT:

local humanoidrootpart = character.HumanoidRootPart
local pathfindingservice = game:GetService("PathfindingService")
local destination = game.Workspace.Destination.Position
local runservice = game:GetService("RunService")

local checker = true

local function computepath()
	if checker == true then
		local raycastparams = RaycastParams.new()
		raycastparams.FilterType = Enum.RaycastFilterType.Exclude
		raycastparams.IgnoreWater = true
		raycastparams.FilterDescendantsInstances = {character:GetChildren()}
		local raycastresult = workspace:Raycast(humanoidrootpart.Position, humanoidrootpart.CFrame.LookVector * Vector3.new(0,0,30), raycastparams)
		local path:Path = pathfindingservice:CreatePath(
			{
				AgentCanJump = true;
			}
		)
		local success, errmessage = pcall(function()
			path:ComputeAsync(humanoidrootpart.Position, destination)
		end)
		if success == true and path.Status == Enum.PathStatus.Success then
			local waypoints:PathWaypoint = path:GetWaypoints()
			for i, v in pairs(waypoints) do
				character.Humanoid:MoveTo(v)
				if waypoints.Action == Enum.PathWaypointAction.Jump then
					character.Humanoid:ChangeState(Enum.HumanoidStateType.Jumping)
				end
			end
			if raycastresult then
				print(raycastresult.Instance.Name)
				computepath()
			end
		else
			wait(errmessage)
		end
	end
end

runservice.Heartbeat:Connect(function(deltatime)
	computepath()
end)

You probably meant v.Position

I tried that also. I am not getting any errors but the character is not moving to the destination.

I have fixed the problem. Go to the character’s children and if anything is anchored unanchor it. I apologize for my ignorance.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.