Attempt to index nil with 'CFrame'

The error showed me this

wait(1)

if script.Parent.Parent.Parent.Parent.Parent:FindFirstChild(“MainParts”) then

script.Parent.Engine.Value = script.Parent.Parent.Parent.Parent.MainParts.Engine

end

local roll = script.Parent.Engine.Value

local Engine = script.Parent.Engine.Value

while game:GetService(“RunService”).RenderStepped:wait() do

script.Parent.union.Rotation = math.deg(math.atan2(Engine.CFrame.lookVector.y,Engine.CFrame.lookVector.y))

end

How are you getting ‘Engine’. If this is your full script then it is erroring because you didn’t define any Engine variable.

There is no such thing as “Rotation”, You meant “Orientation”

Make sure the value of script.Parent.Engine is actually set to a part.

It now says [ invalid argument #3 (Vector3 expected, got number)]

That’s probably from trying to set the rotation. Rotation/Orientation is a vector3, not just one number.

Please format your scripts before posting them
image

The error is probably occurring because Engine is nil, make sure it has a value.
If you want to change the rotation of an object you would do this instead

part.CFrame = CFrame.new(part.Position) * CFrame.Angles(X, Y, Z) -- // You need to specify X, Y and Z in radians! you can do math.rad(num) to convert from degrees to radians. // --