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
 

CFraming more than 1 brick

Previous Thread :: Next Thread 
BobGeorgenworn909 is not online. BobGeorgenworn909
Joined: 03 Apr 2008
Total Posts: 1161
15 Sep 2011 07:24 PM
Someone once told me you can move two bricks at once if they're welded by using something like:

game.Workspace.blox1.CFrame = game.Workspace.blox1.CFrame + Vector3.new(0,0,2)

If they are both anchored, it moves just one brick. If just one is anchored, it moves just one brick. If both are unanchored, it does nothing.

I could move all the children of the model using a loop, but want to see if there is a shorter way.
Report Abuse
BobGeorgenworn909 is not online. BobGeorgenworn909
Joined: 03 Apr 2008
Total Posts: 1161
15 Sep 2011 08:13 PM
bumpz0r
Report Abuse
Catpwnszer is not online. Catpwnszer
Joined: 26 Nov 2010
Total Posts: 631
15 Sep 2011 08:22 PM
a = script.Parent.Parent.Brick1
b = script.Parent.Parent.Brick2

Brick1.CFrame = CFrame.new(Brick1.Position - Vector3.new(0,0,-1))
Brick2.CFrame = CFrame.new(Brick2.Position - Vector3.new(0,0,-1))

In this case both bricks are anchored and both bricks will move.
Report Abuse
Catpwnszer is not online. Catpwnszer
Joined: 26 Nov 2010
Total Posts: 631
15 Sep 2011 08:23 PM
a = script.Parent.Parent.Brick1
b = script.Parent.Parent.Brick2

a.CFrame = CFrame.new(a.Position - Vector3.new(0,0,-1))
b.CFrame = CFrame.new(b.Position - Vector3.new(0,0,-1))

In this case both bricks are anchored and both bricks will move.

Remember that's part of a script.
Report Abuse
grimm343 is not online. grimm343
Joined: 18 Sep 2008
Total Posts: 2796
15 Sep 2011 09:39 PM
You could do that, or make a loop. Example..
Name each brick you want moved as 'something' Their Parent is Workspace.

local z = game.Workspace:GetChildren()

for i=1, #z do
if z[i].Name == "something" then
z[i].CFrame = z[i].CFrame + Vector3.new(0,0,1)
end
end


Another way..
Put all the bricks you want CFramed into a model. Name the model "lolzfosdf".

local bricks = game.Workspace.lolzfosdf:GetChildren()

for i=1, #bricks do
bricks[i].CFrame = bricks[i].CFrame + Vector3.new(0,0,1)
end

To CFrame all of the bricks in a model, and all of the bricks that may be in a model inside of that first model, you would do this.

Name the first 'zcframe'.

local m = game.Workspace.zcframe:GetChildren()

for i=1, #m do
if m[i].className == "Part" then
m[i].CFrame = m[i].CFrame + Vector3.new(0,50,0)
end
local z = m[i]:GetChildren()
for i=1, #z do
if z[i].className == "Part" then
z[i].CFrame = z[i].CFrame + Vector3.new(0,50,0)
end
end
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