All i want to do a script that get Parent positions (XYZ) and subtract it by a variable. Here's the script and error:
Script:
local PositionGoal = {-301.103, 153.029, -497.664} local PositionStart = {script.Parent.Position} local XPosition = PositionGoal[1] local YPosition = PositionGoal[2] local ZPosition = PositionGoal[3] local XGoal = PositionStart[1] local YGoal = PositionStart[2] local ZGoal = PositionStart[3] local MOVEMENT_GOAL = {(XPosition - XGoal), (YPosition - YGoal), (ZPosition - ZGoal)}
Error:
"Workspace.Part.Script:13: bad argument #1 to '?' (Vector3 expected, got number)"
From what i understand, it says that the operation is being expected from vector3. How can i fix that?
As FlamezR has said, you can't subtract ordinary numbers from Vector3s
, if you want to subtract the same amount from x
, y
, and z
then you can simply do myVector3 - Vector3.new(num, num, num)
. Your code is also unnecessarily long, so I'll simplify it for you.
local PositionGoal = Vector3.new(-301.103, 153.029, -497.664) local PositionStart = script.Parent.Position local MOVEMENT_GOAL = PositionStart - PositionGoal
First, you are subtracting a Vector3
off a number, and there is only 1 value in PositionStart
, if you're trying to get the X
, Y
or Z
then do PositionStart[1].X
etc