Why does it error "attempt to perform arithmetic (mul) on nil and number"

Script is below. Any help is appreciated, thanks.

for _,x in pairs(script.Parent.Helicopter.Value.Parent:GetDescendants()) do
	if x:IsA("BasePart") then
		Mass = Mass+x:GetMass()
	end
end

local function Fly()
	if ti == 1 and p < 100 then
		p = p+1
	elseif ti == -1 and p > 0 then
		p = p-1
	end
	Engine.Parent.Pilot.Throttle.Value = p

-- It errors on this below line
	BF.Force = Engine.CFrame:VectorToWorldSpace(Vector3.new(-Engine.Orientation.Z/2,((MaxLift*p)/100)*1.1,Engine.Orientation.X/2))-Vector3.new(Mass*Engine.Velocity.X,Mass*Engine.Velocity.Y,Mass*Engine.Velocity.Z)
	BG.MaxTorque = Vector3.new(p*Settings.PitchSpeed,p*Settings.YawSpeed,p*Settings.RollSpeed)
	BG.CFrame = Engine.CFrame * CFrame.Angles(math.rad(pi*Settings.PitchSpeed),math.rad(yi*Settings.YawSpeed),math.rad(ri*Settings.RollSpeed))
end


2 Likes

which line does it error from?

Line where it says BF.Force ^^

MaxLift is nil, try setting it to some variable for testing
if it still doesn’t work then it’s Mass variable

4 Likes