Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Is part.Position.Y read only?

Asked by
Prioxis 673 Moderation Voter
9 years ago

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
0
I edited my answer a bit, please read Perci1 4988 — 9y

1 answer

Log in to vote
1
Answered by
Perci1 4988 Trusted Moderation Voter Community Moderator
9 years ago

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...

0
oh okay thank you! Prioxis 673 — 9y
0
Couldn't you just do part.Position = part.Position + Vector3.new(0,14,0)? Spongocardo 1991 — 9y
0
Yes, you could. That would probably be a better way. I'll add it in. Perci1 4988 — 9y
Ad

Answer this question