Helicopter helix not spinning

Hello everyone,

I am having trouble getting the helix of my helicopter to spin in Roblox Studio. I have written a script to make it rotate, but it’s not working as expected.

Here is an example image of what I am trying to achieve:

And here is the script that I am using:

local helicopter = script.Parent

local rotorBlades = helicopter:FindFirstChild("Helix")
local rs = game:GetService("ReplicatedStorage")
local module = require(rs.set)
local takeoffHeight = module:getTakeoffHeight()
local rotorSpeed = module:getRotorSpeed()
local flightSpeed = module:getFlightSpeed()

local vel = helicopter:FindFirstChild("LinearVelocity")

local function spinRotor()
	while true do
		for i = 1, 360 do
			rotorBlades.CFrame *= CFrame.Angles(0, math.rad(i), 0)
			wait(0.01)
		end
	end
end

local function takeOff()
	if vel then
		vel.VectorVelocity = Vector3.new(0, flightSpeed, 0)
		wait(2)
		vel.VectorVelocity = Vector3.new(0, 0, 0)
	end
end

if rotorBlades and vel then
	spawn(spinRotor)

	wait(2)

	takeOff()

	while helicopter.PrimaryPart.Position.Y < takeoffHeight do
		vel.VectorVelocity = Vector3.new(0, flightSpeed, 0)
		wait(0.1)
	end

	rotorBlades.CFrame = rotorBlades.CFrame * CFrame.Angles(0, 0, 0)
else
	print("there are missing parts")
end

but the helix is not spinning when I run the script. Instead, I am getting the following error message:

Script 'Workspace.helicopter.Script', Line 15 - function spinRotor - Studio - Script:15

I would greatly appreciate any help or advice that you can offer. Thank you in advance for your time and expertise!

Best regards,

ReyBuxYT (formerly Reikko_5)

Make sure “Helix” is correctly named and make sure it is loaded before trying to use FindFirstChild to find it, you can see if it’s finding it by printing rotorBlades and seeing if it’s nil or not

edit oops didn’t notice you were already checking for rotorBlades