|
| 12 Dec 2016 08:14 PM |
I'm new to coding, I'm trying to code a brick to go back and fourth in between two platforms like a mini Obby. The only thing I can do is make it go in one direction with this simple few lines of code.
while true do script.Parent.Position = script.Parent.Position + Vector3.new(0, 0, 1) wait(0.1) end How would I make it go back and forth in a set location? |
|
|
| Report Abuse |
|
|
alij12
|
  |
| Joined: 03 Oct 2011 |
| Total Posts: 1204 |
|
|
| 12 Dec 2016 08:18 PM |
If the brick is moving along the Z-Axis then just check if the Z position if greater than a certain limit
i.e:
local limit = 10
limit = limit + script.Parent.Position.Z while wait() do if script.Parent.Position.Z < limit then script.Parent.Position = script.Parent.Position + Vector3.new(0,0,1) else script.Parent.Position = script.Parent.Position + Vector3.new(0,0,-1) end end
|
|
|
| Report Abuse |
|
|
|
| 12 Dec 2016 08:24 PM |
| ######################################################################################################################################################################################################################################## |
|
|
| Report Abuse |
|
|
| |
|
| |
|