local function J(J,p)if p==0 then return end local w=p[1]:FindFirstChild("\067\104\101\099\107\112\111\105\110\116")local P=(J.Position-w.Position).magnitude local W=w for p,B in ipairs(p)do w=B:FindFirstChild("\067\104\101\099\107\112\111\105\110\116")local T=(J.Position-w.Position).magnitude if T<P then W=w end end J.CFrame=CFrame.new(J.Position,W.Position)end
-- ================================================================================
-- LOCAL FUNCTIONS
-- ================================================================================
local function UpdateDirection(arrow, targets)
	if targets == 0 then
		return
	end

	local checkpoint = targets[1]:FindFirstChild("Checkpoint")
	local closestDistance = (arrow.Position - checkpoint.Position).magnitude
	local closestTarget = checkpoint

	-- Find nearest target
	for _, target in ipairs(targets) do
		checkpoint = target:FindFirstChild("Checkpoint")
		local distance = (arrow.Position - checkpoint.Position).magnitude
		if distance < closestDistance then
			closestTarget = checkpoint
		end
	end

	-- Point arrow at nearest target
	arrow.CFrame = CFrame.new(arrow.Position, closestTarget.Position)
end -- UpdateDirection()
