Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
|
| 12 May 2014 06:18 PM |
Script: while true do --works fine script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2) wait() end
while true do --This part doesn't work wait(60) script.Parent.CFrame.Angles.new(0, 90, 0) wait(60) script.Parent.CFrame.Angles.new(0, 180, 0) wait(60) script.Parent.CFrame.Angles.new(0, 270, 0) wait(60) script.Parent.CFrame.Angles.new(0,0, 0) end
I wish for it to turn a 90° Angle every 60 seconds, and yet it fails. It just goes strait forward as what the part that works does. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 May 2014 06:19 PM |
The first loop will never end, put it all in 1 loop or use a coroutine. And that's not how you change the rotation.
For 90 degrees: script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0)
And so on |
|
|
| Report Abuse |
|
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
| |
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
|
| 12 May 2014 06:24 PM |
| Though I also might now need help with that top part thanks to you pointing that out to me... |
|
|
| Report Abuse |
|
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
| |
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
| |
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
|
| 12 May 2014 06:39 PM |
I tried changing it: while true do if script.Parent.CFrame.Angles(0, 0, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2) wait() end if script.Parent.CFrame.Angles(0, 90, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(-0.2, 0, 0) wait() end if script.Parent.CFrame.Angles(0, 180, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, 0.2) wait() end if script.Parent.CFrame.Angles(0, 270, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0.2, 0, 0) wait() end end while true do script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0) wait(60) end |
|
|
| Report Abuse |
|
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
| |
|
awesom914
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 4222 |
|
|
| 12 May 2014 06:46 PM |
Ugh... you just aren't doing it right. Use a coroutine! Also instead of using a thousand if statements do script.Parent.CFrame = script.Parent.CFrame * script.Parent.CFrame.Angles.new(0, math.pi/2, 0) |
|
|
| Report Abuse |
|
|
awesom914
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 4222 |
|
|
| 12 May 2014 06:47 PM |
| Wait, I didn't look through it all. Ignore the last part. Still though, coroutine. |
|
|
| Report Abuse |
|
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
| |
|
awesom914
|
  |
| Joined: 06 Mar 2011 |
| Total Posts: 4222 |
|
|
| 12 May 2014 06:56 PM |
| Simpler? Coroutine is simple. |
|
|
| Report Abuse |
|
|
maxomega3
|
  |
| Joined: 11 Jun 2010 |
| Total Posts: 10668 |
|
|
| 12 May 2014 06:58 PM |
Two different scripts in the same brick is much easier. "I've never had to use coroutines in my life" -BetterBe, Owner of RblxDev |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 May 2014 08:19 PM |
LOL inb4loopholeandheusesdelayorspawnfunctionorheartbeatslashstepped
Anyway there is usually a way to avoid using multiple loop, the most common people don't use is the Changed event. |
|
|
| Report Abuse |
|
|
cntkillme
|
  |
| Joined: 07 Apr 2008 |
| Total Posts: 44956 |
|
|
| 12 May 2014 08:20 PM |
Anyways, you're welcome.
coroutine.wrap(function() while true do script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2) wait() end end)()
while true do --This part doesn't work wait(60) script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0) wait(60) script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi, 0) wait(60) script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, 3*math.pi/2, 0) wait(60) script.Parent.CFrame = CFrame.new(script.Parent.Position) end
try that |
|
|
| Report Abuse |
|
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
|
| 13 May 2014 04:45 PM |
Thanks, may need editing though. Need it to move in the direction its facing.
|
|
|
| Report Abuse |
|
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
|
| 13 May 2014 05:25 PM |
Now I'm having this problem
coroutine.wrap(function() while true do if script.Parent.CFrame == CFrame.Angles.new(0, 0, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2) wait() end while true do if script.Parent.CFrame == CFrame.Angles.new(0, 90, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(-0,2, 0, 0) wait() end while true do if script.Parent.CFrame == CFrame.Angles.new(0, 180, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0, 0, -0.2) wait() end while true do if script.Parent.CFrame == CFrame.Angles.new(0, 270, 0) then script.Parent.CFrame = script.Parent.CFrame+Vector3.new(0,2, 0, 0) wait() end end)()
while true do wait(10) script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi/2, 0) wait(10) script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, math.pi, 0) wait(10) script.Parent.CFrame = CFrame.new(script.Parent.Position) * CFrame.Angles(0, 3*math.pi/2, 0) wait(10) script.Parent.CFrame = CFrame.new(script.Parent.Position) end
Will not move the direction it is facing. |
|
|
| Report Abuse |
|
|
Olama5
|
  |
| Joined: 31 Jan 2010 |
| Total Posts: 2827 |
|
| |
|