Attempt to index nil with "CFrame"

I’ve been having trouble with RemoteEvents recently, here’s a LocalScript I fixed up.

local rep = game:GetService("ReplicatedStorage")

rep:WaitForChild("DeliveryTravel").OnClientEvent:Connect(function()
	local plr = game.Players.LocalPlayer
	
	local node = workspace:FindFirstChild("DeliveryNodeFinish")
	local char = plr.Character
	local head = char:WaitForChild("Head")
	local noti = rep:WaitForChild("Notify")
	
	local gui = plr.PlayerGui.MainHUD.GPS
	gui.Visible = true
	
	repeat
		local vector = (head.CFrame.Position - node.CFrame.Position).unit
		local distance = (node.Position - head.Position).Magnitude
		gui.Arrow.Rotation = vector.unit
		gui.Distance.Text = math.floor(distance).. "m"
		wait(0.08)
	until distance < 1
	
	gui.Visible = false
	noti:FireServer(plr, "Mission completed.", 4)
end)

I’m trying to generate a direction vector and a Magnitude of the distance between the player’s head and a part. But, this error comes up in the output:

Attempt to index nil with "CFrame"

And these lines are the origin of the error:

local vector = (head.CFrame.Position - node.CFrame.Position).unit
local distance = (node.Position - head.Position).Magnitude

Any help is appreciated! :roblox_light: :happy1:

The error here is that the node isn’t being found when you reference it, i.e there is nothing in worksapce called DeliveryNodeFinish (or it isn’t a basePart instance), and since nil doesn’t have an attribute called CFrame it returns an error.

You’re correct, and though the part is in the workspace. Because it’s CanCollide = False and unanchored, it just falls though the map and despawns. Thank you