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

How do you multiply Vector 2 values?

I'm trying to update a GUI, and for the values, I'm using, I am doing some math right before applying the. Problem is, every time I try and multiply two vector 2's together, I get "0,0" when I print it out. I honestly don't know whats going on, this is my first time really touching on GUI's so I'm totally out of my depth.

1 comment

0

Thanks for the help guys, but I just figured out that Im working with UDim2 values, and not Vector 2 values, Im very new to doing Gui's, so thanks for you replies but I don't think they would work with UDim2 values.

2 answers

✓ Accepted answer

Vector2 consists of Vector2.X and Vector2.Y. You can multiply them by doing

local oldvector = Vector2.new(5,5)
local newvector = Vector2.new(oldvector.X *3, oldvector.Y * 3)
print(newvector) -- (15,15)

You can also multiply vectors together

local oldvector = Vector2.new(5,5)
local multiplyvector = Vector2.new(3,3)
local newvector = oldvector * newvector
print(newvector) -- (15,15)

Multiplying a vector by a number will also multiply each one by that number

local oldvector = Vector2.new(5,5)
local newvector = oldvector * 3
print(newvector) -- (15,15)

2 comments

0

Although, you did answer the question I asked, I just dident ask the right question for the project im doing.

0

No problem, its easy to get confused with coding, there is so many variables and values. Nonetheless glad you got it working!

Have you perhaps tried Vector2 * Vector2?

If you have good job, if your result is then still 0,0 that means that either the left or the right value contains 0 values, (since y'know, 0 * something is always 0)

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