Position.X/Y/Z Not Working

Hello Roblox Dev Community,

Info
So i am trying to position an part (an hair that’s an part) to an character. But the thing is that if i position the CFrame exactly to the head, it would stick of a little. So i made an code for that.

		newUserHair.Position.X = char.Head.Position.X + newUserHair.SpecialHair.Value.X
		newUserHair.Position.Y = char.Head.Position.Y + newUserHair.SpecialHair.Value.Y
		newUserHair.Position.Z = char.Head.Position.Z + newUserHair.SpecialHair.Value.Z

It doesn’t works, and it comes with this error in the output:

X cannot be assigned to - Client - LocalScript:62 (The first line of code, that i wrote before.)

Achieve
So i made an value inside of the hair called, SpecialHair. It’s an Vector Value with as example:

Vector3.new(0, 0.2, 0)

and then the script just positions it to the head + the value inside of it. That’s what i want to achieve.

Forgot to mention!
It’s written down inside of an local-script.

Hope everyone has an good day, stay save and healthy.
:pray: :wave:

You can’t change the X, Y and Z properties of an existing vector. You need to replace the position vector with a new one.

newUserHair.Position = char.Head.Position + newUserHair.SpecialHair.Value
1 Like

For me it still doesn’t works, but it doesn’t gives me any errors. Should i try it on an server-script?

Usually with this error, you get it because you can’t put positions such as y and x or something. In a client/local script

Try the exact same script but in a server script

1 Like

@Icy7812 and @RoBoPoJu We’re right, thank you. The problem was about it being on the client side. So @RoBoPoJu was right about the script and @Icy7812 was right about the client thing, Thank you!
:+1:

1 Like

You can’t change individual positional values in a Vector3, just use Vector3.new() to set each individual one

1 Like

He said the post was solved? I’m wondering why your trying to get my solutions :confused:
Not cool man. Also is not a relevant solution lol.

1 Like

I’m just giving some advice, I’m not stealing your solution. The metatable for the Vector3 is locked, you should be using Vector3.new() for good practice. :slight_smile:

2 Likes

Thank you for explaining :slight_smile: I know that @Icy7812 Got the solution, but still thank you for explaining.