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

How do I only move the Y,Z position values?

Asked by 4 years ago

How can I move only the Y and Z position values, and leave the X the same?

Example:

local part = game.Workspace.Part

part.Position.XValue = 1
part.Position.YValue = 5
part.Position.ZValue = 1



2 answers

Log in to vote
0
Answered by 4 years ago

you can use vector3.new(x,y,z)

part.Position = part.Position + Vector3.new(0,5,1)
Ad
Log in to vote
0
Answered by 4 years ago

Use Vector3.new(), it makes a value with 3 vectors.

local part = game.Workspace.Part

local x = 1
local y = 5 --change to whatever you want
local z = 1 --change to whatever you want

part.Position = Vector3.new(x, y, z)

If you want to repeatedly move in random directions, try this:

local part = game.Workspace.Part

while true do

local x = 1
local y = math.random(1, 10) --change to whatever you want
local z = math.random(1, 10) --change to whatever you want

part.Position = Vector3.new(x, y, z)
wait(1)
end

Answer this question