Add to the y axis on a vector3 variable

Im trying to spawn a block where the mouse clicked, but like 10 studs off the baseplate. The problem is that for example: This is the vector3 variable “local obj = Vector3.new(4, 0, 7)” after i use getmouse.hit.position, and i want to change the y axis to 10. Because i use “local obj = game.Players.Localplayer:GetMouse().hit.Position” i cant just write "local obj = Vector3.new(4, 10, 7). I need to somehow get the mouse position and higher the y axis but not the other axis.

You can just add a Vector3? So obj + Vector.new(0,10,0), that is all you need to do.

1 Like

Since those properties on Vector3 are read-only, you’ll have to create a new one:

local newVector = Vector3.new(oldVector.X, 10, oldVector.Z)
1 Like

You could do vector += 10 * Vector3.yAxis

2 Likes

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