SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 08 Nov 2016 09:52 PM |
This is the code local self = script.Parent local pp = script.Parent.PrimaryPart
function TurnBox() print("Turning Box!") local cf = pp.CFrame * CFrame.Angles( math.rad(math.random(-360, 360)), math.rad(math.random(-360, 360)), math.rad(math.random(-360, 360)) ) for i=0.001,1,0.001 do self:SetPrimaryPartCFrame(pp.CFrame:lerp(cf, i)) wait(0.06) end end
print("Running Version 0.0.2!") while true do print("Looping!") TurnBox() t = math.random(2, 5) wait(t) end
it's a global script inside of a model, it's supposed to turn a big box but aftero nly one loop the while loop stops running |
|
|
| Report Abuse |
|
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 08 Nov 2016 10:02 PM |
Its probably not exiting from the for loop. Add another print statement to print the value of i in there
If you're seeing this post, it means I'm either dead (leaving behind a very fabulous looking corpse) or my soul has been captured by pixies! |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 08 Nov 2016 10:07 PM |
hmmm you're right. is there any way to fix that? here are my attempts so far and none have worked
attempt 1: for i=1,1000,1 do self:SetPrimaryPartCFrame(pp.CFrame:lerp(cf, i/1000)) if i >= 1000 then break end wait(0.06) end print("Done!")
attempt 2: local v = 1 for i=1,1000 do self:SetPrimaryPartCFrame(pp.CFrame:lerp(cf, v/1000)) v = v + 1 if v >= 1000 then break end wait(0.06) end print("Done!")
|
|
|
| Report Abuse |
|
|
L2000
|
  |
| Joined: 03 Apr 2008 |
| Total Posts: 77448 |
|
|
| 08 Nov 2016 10:08 PM |
What's the output you're getting? Like, is i changing? Is it slow?
If you're seeing this post, it means I'm either dead (leaving behind a very fabulous looking corpse) or my soul has been captured by pixies! |
|
|
| Report Abuse |
|
|
SurKipper
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 435 |
|
|
| 08 Nov 2016 10:13 PM |
Yea, 'i' was a bit slow so I changed it to this:
for i=1,100,1 do self:SetPrimaryPartCFrame(pp.CFrame:lerp(cf, i/1000)) print(i) if i >= 100 then break end wait(0.06) end
posted for problem solving purposes
thanks for the help! |
|
|
| Report Abuse |
|
|