X cannot be assigned to

So, I’m a bit new to Lua. I’ve only been scripting with it for like a month and a half. I came across a problem when trying to assign the position of an object.

script.Parent.Position.X = 136
script.Parent.Position.Y = -20
script.Parent.Position.Z = 112

The error message for it said “X cannot be assigned to” Anyone here got any solutions?

10 Likes

Assign the Position a Vector3 value once, not an integer thrice.

script.Parent.Position = Vector3.new(136, -20, 112) -- vector
21 Likes

Unfortunately Vector3 is immutable meaning you can’t change it. What you will have to do is

script.Parent.Position = Vector3.new(136, -20, 112)

to create a new instance of Vector3 and use that as the position

7 Likes

Alright, thanks for the help.

(30 characters.)

3 Likes