I want to make a sliding part that can work anywhere, but I can't seem to change the Z position without moving the X and Y. I've tried this code
while true do script.Parent.Position.Z = Vector3.new(5) print(script.Parent.Position.Z) wait(0.1) end
Help?
as TheeDeathCaster said, you can't just change the Z coordinate, you need to change the whole position, e.g
script.Parent.Position = Vector3.new(script.Parent.Position.X, script.Parent.Position.Y, 5) -- This will just change the Z coordinate.
You cannot assign the individual properties of a Vector3. But what you can do is add/subtract/multiply/divide a Vector3 to another Vector3:
while true do script.Parent.Position = script.Parent.Position + Vector3.new(0, 0, 5) wait(0.1) end
This here is just adding 5 to the Z axis. And 0 to the other axes so the Z axis is the only one changing.