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: Moving Part

Previous Thread :: Next Thread 
Z2008 is not online. Z2008
Joined: 28 Dec 2008
Total Posts: 248
28 Sep 2014 06:25 PM
I want to make a brick move into the baseplate so it disappears into the baseplate, but I can't seem to move it negative in the y-axis. As if it doesn't want to go through the baseplate (even when I made it unCanCollide). Here's the script:

b=game.Workspace.MovingPart
for i=-1,-10 do
b.CFrame=CFrame.new(364.3,i,689)
wait(.3)
end

It works when i=1,10. Just not negative.
Report Abuse
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
28 Sep 2014 06:29 PM
b=game.Workspace.MovingPart
for i=1,10 do
c = i*-1
b.CFrame=CFrame.new(364.3,c,689)
wait(.3)
end


Just keep it simple.
Report Abuse
Z2008 is not online. Z2008
Joined: 28 Dec 2008
Total Posts: 248
28 Sep 2014 06:32 PM
Thanks, I always forget how useful variables can be.
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
28 Sep 2014 07:19 PM
Actually, the OP was closer with his original one, just needed one small edit:

b=game.Workspace.MovingPart
for i=-1,-10, -1 do
b.CFrame=CFrame.new(364.3,i,689)
wait(.3)
end
Report Abuse
EPICJAKEISCOOL is not online. EPICJAKEISCOOL
Joined: 07 Feb 2013
Total Posts: 1756
28 Sep 2014 07:22 PM
Oh, how I hate 'i'.

for I=1,100 do
Part.CFrame = Part.CFrame + Vector3.new(0,0.3,0)
end
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
28 Sep 2014 07:23 PM
*jake
The whole point of the numeric loop is to have access to the variable that tells you what iteration it is currently on. It also looks better when you use the i.
Report Abuse
EPICJAKEISCOOL is not online. EPICJAKEISCOOL
Joined: 07 Feb 2013
Total Posts: 1756
28 Sep 2014 07:24 PM
I know, just having i replace a coordinate just drives me insane.

lol
Report Abuse
opplo is not online. opplo
Joined: 09 Dec 2008
Total Posts: 5320
28 Sep 2014 07:28 PM
@blockoo
There's more than one way to solve a problem, all of which are correct. Efficiency isn't of the uppermost importance with this piece of code. So putting it in a context which is most understandable to the OP is best
Report Abuse
blockoo is not online. blockoo
Joined: 08 Nov 2007
Total Posts: 17202
28 Sep 2014 07:32 PM
Well, I'll explain then.

A for numeric loop has 2 arguments, a start, an end, and an increment. The increment argument defaults to 1 unless it is set. So, OP, in your code, you told it to count from -1 to -10, but in increments of +1 which obviously won't work. So you simply need to tell it to count by -1 instead.
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