Z2008
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 248 |
|
|
| 28 Sep 2014 06:25 PM |
I want to make a brick move into the baseplate so it disappears into the baseplate, but I can't seem to move it negative in the y-axis. As if it doesn't want to go through the baseplate (even when I made it unCanCollide). Here's the script:
b=game.Workspace.MovingPart for i=-1,-10 do b.CFrame=CFrame.new(364.3,i,689) wait(.3) end
It works when i=1,10. Just not negative. |
|
|
| Report Abuse |
|
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 28 Sep 2014 06:29 PM |
b=game.Workspace.MovingPart for i=1,10 do c = i*-1 b.CFrame=CFrame.new(364.3,c,689) wait(.3) end
Just keep it simple. |
|
|
| Report Abuse |
|
|
Z2008
|
  |
| Joined: 28 Dec 2008 |
| Total Posts: 248 |
|
|
| 28 Sep 2014 06:32 PM |
| Thanks, I always forget how useful variables can be. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 28 Sep 2014 07:19 PM |
Actually, the OP was closer with his original one, just needed one small edit:
b=game.Workspace.MovingPart for i=-1,-10, -1 do b.CFrame=CFrame.new(364.3,i,689) wait(.3) end |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 07:22 PM |
Oh, how I hate 'i'.
for I=1,100 do Part.CFrame = Part.CFrame + Vector3.new(0,0.3,0) end |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 28 Sep 2014 07:23 PM |
*jake The whole point of the numeric loop is to have access to the variable that tells you what iteration it is currently on. It also looks better when you use the i. |
|
|
| Report Abuse |
|
|
|
| 28 Sep 2014 07:24 PM |
I know, just having i replace a coordinate just drives me insane.
lol |
|
|
| Report Abuse |
|
|
opplo
|
  |
| Joined: 09 Dec 2008 |
| Total Posts: 5320 |
|
|
| 28 Sep 2014 07:28 PM |
@blockoo There's more than one way to solve a problem, all of which are correct. Efficiency isn't of the uppermost importance with this piece of code. So putting it in a context which is most understandable to the OP is best |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 28 Sep 2014 07:32 PM |
Well, I'll explain then.
A for numeric loop has 2 arguments, a start, an end, and an increment. The increment argument defaults to 1 unless it is set. So, OP, in your code, you told it to count from -1 to -10, but in increments of +1 which obviously won't work. So you simply need to tell it to count by -1 instead. |
|
|
| Report Abuse |
|
|