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 » Scripting Helpers
Home Search
 

Re: My Doors Like To Fly Off Into Oblivion

Previous Thread :: Next Thread 
IceSIipper is not online. IceSIipper
Joined: 23 Mar 2013
Total Posts: 10447
18 Jun 2014 01:09 AM
I use this script to make doors slide upwards. I used what I new I could but it doesn't stop my doors from moving. Does anyone know how to make my door go up five studs, stop, and then some back down?

for i=0,5, .01 do
door.CFrame = door.CFrame * CFrame.new(0,(i),0)
wait(.01)
end

wait(4)

for i=5,0 -.01 do
door.CFrame = door.CFrame * CFrame.new(0,(i),0)
wait(.01)
end
Report Abuse
konichiwah91 is not online. konichiwah91
Joined: 18 Jan 2011
Total Posts: 3677
18 Jun 2014 01:33 AM
Im pretty sure I've had this problem before. Have you tried anchoring it?
Report Abuse
IceSIipper is not online. IceSIipper
Joined: 23 Mar 2013
Total Posts: 10447
18 Jun 2014 11:17 AM
They are already anchored
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Jun 2014 11:22 AM
Use .05 and not .01. It'll work then.
Report Abuse
filiptibell is online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
18 Jun 2014 11:24 AM
for i=0,5, .01 do
door.CFrame = door.CFrame * CFrame.new(0,.01,0)
wait(.01)
end

wait(4)

for i=5,0 -.01 do
door.CFrame = door.CFrame * CFrame.new(0,-.01,0)
wait(.01)
end

~The herp lerped a derp~
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Jun 2014 11:31 AM
@Filiptibell

Doesn't change anything. The for loop will still never stop. You need to notice that the .01 will never equal 5 exactly.
Report Abuse
protectiveEBob is not online. protectiveEBob
Joined: 09 Jul 2012
Total Posts: 1297
18 Jun 2014 11:35 AM
for i=1, 50 do
door.CFrame = door.CFrame * CFrame.new(0,.01,0)
wait()
end

wait(4)

for i=1, 50 do
door.CFrame = door.CFrame * CFrame.new(0,-.01,0)
wait()
end
Report Abuse
filiptibell is online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
18 Jun 2014 11:40 AM
@DrMathematica

5/.01 = 500
Unless one step in the loop isn't one step (which it always is), the loop will complete after 500 cycles. How's the math going?

~The herp lerped a derp~
Report Abuse
IceSIipper is not online. IceSIipper
Joined: 23 Mar 2013
Total Posts: 10447
18 Jun 2014 11:40 AM
@DR that worked but it doesnt come down
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Jun 2014 11:43 AM
It's computing. Do you not know how decimals are handled? Every wondered why, for instance, in GUIs, your numbers (.1) might turn into .100000012 or .999999998?

Because of "floating point precision." The decimals need to be able to be expressed by a power of 2.
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Jun 2014 11:44 AM
"@DR that worked but it doesnt come down"

Turn it to -.05 too... on the second one.
Report Abuse
IceSIipper is not online. IceSIipper
Joined: 23 Mar 2013
Total Posts: 10447
18 Jun 2014 11:44 AM
I did that already
Report Abuse
IceSIipper is not online. IceSIipper
Joined: 23 Mar 2013
Total Posts: 10447
18 Jun 2014 11:48 AM
bump
Report Abuse
filiptibell is online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
18 Jun 2014 11:48 AM
Well, too bad it works if I am supposedly wrong then...

~The herp lerped a derp~
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Jun 2014 11:50 AM
Unfortunately, you're lying.
Report Abuse
filiptibell is online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
18 Jun 2014 11:55 AM
number = 0
for i = 0, 99 do
wait()
number = number + .01
print(number)
end

Try it, it's full of lies.

~The herp lerped a derp~
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Jun 2014 11:59 AM
You moron, look at the difference between what you posted earlier (which is what we talked about) and what you just posted.

"for i=0,5, .01 do "

"for i = 0, 99 do "

Each iteration checks to see if 'i' is equal to the end value yet. Like I said, adding .01 to 0 continuously will never equal 5. .01 cannot be expressed by a power of 2 and therefore cannot equal 5 (which can be expressed as a power of 2)

In your case you just showed, OF COURSE it will get to the end. It's adding by 1 - a normal number and not a floating point.
Report Abuse
filiptibell is online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
18 Jun 2014 12:02 PM
So, I am a moron for using a loop differently?
woah.

The number variable used still gets changed by .01, the example is still valid...
I'd appreciate if you take all that anger and go smack a pillow or something

~The herp lerped a derp~
Report Abuse
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
18 Jun 2014 12:03 PM
um i dont know why people make this so complicated.


The reason it may not work, is
1.) The Y Cframe might be different than what you expect, since CFrame takes in rotation
2.) You keep rotating by an exponential increment which can cause it to go really high




Here is a quick fix:

for i=0,5, .01 do
door.CFrame = door.CFrame + Vector3.new(0,.1,0)
wait(.01)
end

wait(4)

for i=5,0 -.01 do
door.CFrame = door.CFrame + Vector3.new(0,-.1,0)
wait(.01)
end
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
18 Jun 2014 12:04 PM
"The number variable used still gets changed by .01, the example is still valid..."

No, fool. Look at the iteration differences. The first loop is adding to the 'i' increment by .01. The second is by 1 (the default).

It doesn't matter what you do to the CFrame. Why would that affect the for loop?
Report Abuse
DigitalVeer is not online. DigitalVeer
Joined: 23 Jun 2009
Total Posts: 4182
18 Jun 2014 12:04 PM
In my previous post, I meant to say "CFraming" instead of "Rotating" exponentially
Report Abuse
filiptibell is online. filiptibell
Joined: 10 Mar 2013
Total Posts: 2362
18 Jun 2014 12:06 PM
number = 0
for i = 0, 1, .01 do
wait()
number = number + .01
print(number)
end

Did it the way you wanted instead.
Now go try it and check the output.

~The herp lerped a derp~
Report Abuse
islandmaker2012 is not online. islandmaker2012
Joined: 07 Nov 2012
Total Posts: 9327
18 Jun 2014 12:38 PM
don't be dumb

what a for loop does:

starts as startnumber, goes up by increment, UNTIL its larger or equal to endnumber(or smaller or equal to endnumber) depends if increment is -num or +num

for I=0,5,0.01 do
print(I)
end

the loop does end, don't pretend you know how it works

for I=5,0,-0.01 do
print(I)
end

and so does this one

for I=startnumber,endnumber,increment do

end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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