Vector3s are immutable. In other words, they don’t change. In order to set a specific axis value, you have to create a whole new Vector3. Don’t worry, Roblox is very optimized for this.
local vec = Vector3.new(1, 2, 3)
-- Change Z to 10:
vec = Vector3.new(vec.X, vec.Y, 10)