Help with spawn() function

Hello, so, to be honest, I am not very experienced with spawn() function at all, actually, this is the first time I am using this function.

I made a for loop inside a spawn() function:

local RegRay = rray:Clone()
		RegRay:SetPrimaryPartCFrame(Char.HumanoidRootPart.CFrame * CFrame.new(0,0,5)) 
		RegRay:SetPrimaryPartCFrame(CFrame.new((Char.HumanoidRootPart.CFrame * CFrame.new(0, 0, 5)).Position, Mouse.Position) * CFrame.Angles(0, math.rad(90), 39.3))
		RegRay.Parent = workspace
spawn(function(f)
		for i = 1,100 do wait()
		RegRay.EnergyBeam.Transparency = RegRay.EnergyBeam.Transparency + 0.01
		RegRay.FireBeam.Transparency = RegRay.FireBeam.Transparency + 0.01
		RegRay.FullRing1.Transparency = RegRay.FullRing1.Transparency + 0.01
		RegRay.FullRing2.Transparency = RegRay.FullRing2.Transparency + 0.01
		RegRay.FullRing3.Transparency = RegRay.FullRing3.Transparency + 0.01
		RegRay.FullRing4.Transparency = RegRay.FullRing4.Transparency + 0.01
		RegRay.MeshPart.Transparency = RegRay.MeshPart.Transparency + 0.01
		end 
end)

Although for some reason it prints an error:
“EnergyBeam is not a valid member of Model” - even though it’s clearly there.
https://gyazo.com/78285977a42fe47357d12835d2f3c8a6
Thank you for your time.

That’s because the script runs too fast before the EnergyBeam loads, you have to define them in a variable and use :WaitForChild() to wait them to load

local EnergyBeam = RegRay:WaitForChild("EnergyBeam")

same with the other ones too, it just haven’t error because the first error you have stops the script