Attempt to index number with 'LookVector' error

So I’m tryna script something that shoots glass backward when shot with a gun, to get the vector the glass shoots back at, I’m getting the guns ‘LookVector’.

The issue I’m having is that I’m trying to multiply the look vector 2 and I’m getting an error. (Error shown in tittle)

Here’s the piece code I’m having trouble with:

local prtVelocityX = gun.CFrame.X.LookVector-(gun.CFrame.X.LookVector*2)
local prtVelocityY = gun.CFrame.Y.LookVector-(gun.CFrame.Y.LookVector*2)
local prtVelocityZ = gun.CFrame.Z.lookVector-(gun.CFrame.Z.LookVector*2)

Pretty sure that .lookVector is a property of CFrame, and not of the axis’. A potential fix to the code is change the order of the indexing: CFrame.lookVector.Axis.

Also, you have used Uppercase on the 2 first times you indexed lookVector, and the third one, you used lowercase.

1 Like

Now it’s returning the error, “Axis is not a valid member of Vector3”

It needs to be a CFrame not a Vector3

I’m pretty sure it is a CFrame, here’s the line the error is on:

local prtVelocityX = gun.CFrame.LookVector.Axis.X-(gun.CFrame.LookVector.Axis.X*2)

Here’s the error:
image

oh Axis is not a valid member of Vector3 use

LookVector.X

Instead of

LookVector.Axis.X

Axis isnt a LookVector property