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

Vector3 and Number Randomly?

Basically, my friend got an error called "attempt to perform arithmetic (sub) on vector3 and number." The line of code that caused this is in this discord attachment link. https://cdn.discordapp.com/attachments/993644972224036965/1046595153818832926/image.png

the vector3 and number error message is in this discord attachment link. https://cdn.discordapp.com/attachments/993644972224036965/1046594002167804015/image.png he doesnt know how to fix this and a scripter isnt responding to him either so i made this question on how to fix this. hope maybe someone can help me. if its not understandable enough then i dont know??

3 comments

0

The link does not work

0

ofc it doesn't work because you're not in their discord server/conversation

0

Sorry for not doing the images thing instead. i dont kow how to put them for now.

2 answers

I can’t view the code, if you could post it here I could be more of a help.

But from what I can tell you’re likely trying to subtract a number from a Vector3 value. Try removing the subtraction sign and see if it goes away. If it does then subtract the value some other way.

1 comment

0

I would put the images, but i dont know how yet since i only joined yesterday to help my friend on this specific one line of code.

You are trying to subtract a Number from a Vector3 value. "monster.Position" is a vector3 value and cannot be in the same arithmetic as a different type of value (number)

Try: ~~~~~~~~~~~~~~~~~ if monster.Position.Magnitude - handle.Position.Magnitude < 5 then


Adding magnitude will convert the vector3 into a single number.

1 comment

0

idk why the formatting didnt work, heres the block of code: if monster.Position.Magnitude - handle.Position.Magnitude < 5 then

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