#How to fix "attempt to perform arithmetic (sub) on Vector3 and number" error?

1 messages · Page 1 of 1 (latest)

winter seal
#

I have a script that moves a part to the 3D position of a player's mouse cursor. In order to stop the cursor from following the camera, I decided to have the location of the part stop moving on a given access once the difference between the part and player exceeds a set range. However, I'm getting the error "attempt to perform arithmetic (sub) on Vector3 and number" whenever the range is exceeded. What should I do?

nimble bronze
#

print mp3dpos and distance mag and range mag

#

@winter seal

winter seal
nimble bronze
#

magnitude seems to be a regular number

lost juniperBOT
#

studio** You are now Level 10! **studio

nimble bronze
#

so

#

mp3dpos is a vector 3 I assume

winter seal
#

yep

nimble bronze
#

and you can minus numbers from a vector 3

winter seal
rugged yarrow
#

The .Origin returns a vector if I remember correctly

nimble bronze
winter seal
#

so should i just do each axis individually

nimble bronze
#

yh that's what I would try

#

probably a better way of going about it

#

but see if that works

winter seal
#

alrighty

#

at least the function's firing

nimble bronze
winter seal
#

i just want it to stop where it is upon exceeding the range

nimble bronze
#

I'm not sure about what the maths behind that would be

winter seal
#

ah kk

#

yeah theres def some formula i gotta get

#

thx for the help w the syntax error thing tho

nimble bronze
#

no problem

dim sky
#

well

#

you would do for i = 1,#string.split(vector3value,", ") do

#

then you would go like

#

im lying

#

just do vector3.New(string.split(vector3value,", ")[1],string.split(vector3value,", ")[2],string.split(vector3value,", ")[3])

#

that should do

#

it makes the string into a vector 3

#

wait

#

okay

#

ill write the whole script here

#
local vectortable = string.split(vectorvariable,", " 
local x = vectortable[1]
local y = vectortable[2]
local z = vectortable[3]
-- do subtracting here

vector3.New(x,y,z)
#

boom

#

yourwelcome

#

50 robux pl;ease

#

wait

#

FUCK

#
local vectortable = string.split(vectorvariable,", " 
local x = tonumber(vectortable[1])
local y = tonumber(vectortable[2])
local z = tonumber(vectortable[3])
-- do subtracting here

vector3.New
(x,y,z)
#

thats thew script that will work

#

replace vector variable with whatever u need

#

all in a days work

winter seal
dim sky
winter seal
#

ahh

#

oooh that'll be handy

#

thx