Vector doesn't want to assign X or Y

Hello everybody,

Recently, I worked on a small project with vectors, as I encountered an error. I tried to solve the problem by debugging, but couldn’t find it at first. But then, after some time, I narrated the problem down to two lines of code:


local vector = Vector2.new(0,0)

vector.X = 1

These lines of code gave me the following error message:

Roblox Studio error message

I then tried this in a completely new place, inside of a server script, and still got the same result.

I can’t explain myself why this is happening, so if anyone can help me deal with this error, then it would be highly appreciated.

You have to construct a new vector if you want to change any components.

local vector = Vector2.new(0, 0)
vector = Vector2.new(1, vector.Y)

Thanks! For all the years I am coding now, I just recently found out that you can’t change vectors, because they are read only. Burh.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.