Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

invalid argument #1 to 'new' (Vector3 expected, got number)?

I've been playing around with beizier curves, and I recently got this error. Heres the line at error:

local SPos = FX.Position
local MPos = Config.Location.Value
local Pos = CFrame.new(SPos,MPos)*CFrame.new(0,0-(SPos-MPos).magnitude/2).p

1 comment

0

Seems like to me your MPos is a number value and not a vector3 value, also your 2nd CFrame only has 2 values I think you might've forgotten a "," or just forgotten the value entirely.

1 answer

✓ Accepted answer

In the CFrame.new(0,0-(SPos-MPos).magnitude/2) part you define at least 1 (possibly 2) number values.

CFrame however does not have a constructor that contains a number and another number/Vector3. (Depends on what MPos is)

Your only options are:

  • An empty constructor

  • A single Vector3 providing the position part of a CFrame

  • Two Vector3's providing the position and the place where to look at (defines the orientation)

  • Three numbers providing the x,y,z for the position

  • Two more constructors which have you type in the x,y,z components aswell as a quaternion or the rotation matrix

Your construction does not match any of these constructors. By the looks of it you can just add a single number at the end of the constructor to make sure you have the valid x,y,z constructor.

1 comment

0

i forgot a comma i fixed this issue a couple days ago. Sorry ill just mark your answer since its basically the same thing.

This discussion is preserved as it was. New answers, comments, and votes are closed.