Why the first loop runs slower than the second loop?

I dont understand why the first loop is slower than the second loop? why does it happen?

local a = script.Parent.Head.Neck

local s = tick()
for i=1,1000000 do
	script.Parent.Head.Neck.C0 = script.Parent.Head.Neck.C0 * CFrame.Angles(0,0,math.rad(1))
end
print(tick()-s)
wait(2)
local d = tick()
for i=1,1000000 do
	a.C0 = a.C0 * CFrame.Angles(0,0,math.rad(1))
end
print(tick()-d)

Every time that the first one loops, it has to navigate to the script’s parent, then “head”, then “neck”, which takes time.

The second loop stored the value of the first search (a), so it doesn’t need to carry out the navigation each loop. Because of this, it is faster.