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

Is part.Position.Y read only?

So I'm trying to change the parts Y Value by adding 15 to it but it throws an error saying that it can't be assigned to how would I fix this or how would I accomplish what i'm doing another way?

this is the line of code that i'm dealing with

	NewPart.Position.Y = NewPart.Position.Y + 14

1 comment

0

I edited my answer a bit, please read

1 answer

✓ Accepted answer

Yes, it is read-only, so you can't edit it directly. It's pretty easy to do what you want, though. All you need to do is set the position like normal, with Vector3.new. Now we can use the x/y/z properties, and it won't matter that they are read-only, since Vector3.new takes three numbers anyways.

part.Position = Vector3.new(
	part.Position.X,
	part.Position.Y + 14,
	part.Position.Z
)

As Spongocardo pointed out, it would probably be better to simply add a Vector3 to the current position, like so;

part.Position = part.Position + Vector3.new(0, 14, 0)

I apologize for overlooking this originally...

3 comments

0

oh okay thank you!

0

Couldn't you just do part.Position = part.Position + Vector3.new(0,14,0)?

0

Yes, you could. That would probably be a better way. I'll add it in.

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