hansotto
|
  |
| Joined: 21 Apr 2010 |
| Total Posts: 233 |
|
|
| 21 Sep 2013 03:31 PM |
I'm trying to make a script that makes its parent spin Why does this not work?
i = 0 while true do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(i,0,0) wait() end i = i + 1 |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2013 03:33 PM |
Because you're adding the +1 after the while true do, which it will never get to it because it's looping forever. So I suggest you move the 'i = i + 1' into the while loop.
i = 0 while true do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(i,0,0) i = i + 1 wait(0.2) -- wait() is too fast. end
~rekt get |
|
|
| Report Abuse |
|
|
hansotto
|
  |
| Joined: 21 Apr 2010 |
| Total Posts: 233 |
|
|
| 21 Sep 2013 03:34 PM |
Damn i'm dumb... :I
Thank you |
|
|
| Report Abuse |
|
|
hansotto
|
  |
| Joined: 21 Apr 2010 |
| Total Posts: 233 |
|
|
| 21 Sep 2013 03:37 PM |
It spins now but, it keeps gaining more speed and then it stops and starts over and gains speed and over and over :P
i = 0 while 1 + 1 == 2 do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(i,0,0) wait(0.2) i = i + 0.05 end |
|
|
| Report Abuse |
|
|
|
| 21 Sep 2013 03:40 PM |
Well, you are multiplying by i, which means if i = 1000, it will shift to 1000. Thus, looking like it teleports. Try this:
while wait() do for i = 1, 360, 1 do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(i, 0, 0) wait() end end
~rekt get |
|
|
| Report Abuse |
|
|
Apatheia
|
  |
| Joined: 16 Aug 2013 |
| Total Posts: 198 |
|
|
| 21 Sep 2013 03:41 PM |
That's because i is increasing, so the amount rotated increases too.
while wait(0.2) do script.Parent.CFrame = script.Parent.CFrame * CFrame.Angles(0.05,0,0) end |
|
|
| Report Abuse |
|
|
hansotto
|
  |
| Joined: 21 Apr 2010 |
| Total Posts: 233 |
|
| |
|
Apatheia
|
  |
| Joined: 16 Aug 2013 |
| Total Posts: 198 |
|
|
| 21 Sep 2013 03:42 PM |
@black
No, it's not multiplying; the * operator in CFrames just add both together. |
|
|
| Report Abuse |
|
|
hansotto
|
  |
| Joined: 21 Apr 2010 |
| Total Posts: 233 |
|
| |
|