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
1 | while true do |
2 | script.Parent.Position.Z = Vector 3. new( 5 ) |
3 | print (script.Parent.Position.Z) |
4 | wait( 0.1 ) |
5 | end |
Help?
as TheeDeathCaster said, you can't just change the Z coordinate, you need to change the whole position, e.g
1 | script.Parent.Position = Vector 3. 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:
1 | while true do |
2 | script.Parent.Position = script.Parent.Position + Vector 3. new( 0 , 0 , 5 ) |
3 | wait( 0.1 ) |
4 | 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.