generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: While loop won't run

Previous Thread :: Next Thread 
SurKipper is not online. 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 is not online. 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 is not online. 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 is not online. 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 is not online. 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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image