What is the best way to change only one value in Vector3.new()?

Let’s say we have Vector3.new() and I only want to change the Y value.

local values = Vector3.new(0, 0, 0)
values = Vector3.new(values.X, 10, values.Z)

But I am sceptical that what if it will change all three of them? And if we would want to change only Y value while giving the possibilities to change the other two freely without the script?

You can use your current way or you can add/subtract one vector from another. The current method works fine.

1 Like

I’ve always done it like this, it removes a potential source of error like swapping or duplicating the X and Z values by mistake. Also looks cleaner IMO.

values = values + Vector3.new(0, 10, 0)
1 Like

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