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
 

How do I weld all the parts in a model?

Previous Thread :: Next Thread 
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
17 Mar 2015 06:48 PM
What is the simplest way to weld all the parts in a model to each other, a collection of parts grouped together, wanting to save their positions and rotations relative to each other?
Report Abuse
IoIiderp is not online. IoIiderp
Joined: 05 Feb 2012
Total Posts: 8613
17 Mar 2015 06:50 PM
free models
Report Abuse
kert109 is not online. kert109
Joined: 31 Dec 2009
Total Posts: 681
17 Mar 2015 06:53 PM
mainP = bla

for i, v in pairs(ThatModelYouWant:children())

Weld = Instance.new("Weld",mainP)
Weld.Part0 = mainP
Weld.Part1 = v
Weld.C0 = mainP.CFrame:toObjectSpace(v.CFrame)
-- if this doesn't work, switch mainP.CFrame and v.CFrame.
end

Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
17 Mar 2015 07:00 PM
that makes all the parts seemingly welded to each other, but also cframed into the exact same position, so all the parts in the model have the same position, and i don't want that

i want them to keep their positions relative to each other, that sort of sandwiches them :O
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
17 Mar 2015 07:06 PM
It works if I anchor it all.
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
17 Mar 2015 07:40 PM
@Kert

Two problems

1) Ew, you used C0. Bad practice when C0 is mainly reserved for swing joints
2) You need to set the C1 before setting the parts, unless parented afterwards
Xtra 3) Also, :toObjectSpace turns the preceding CFrame to the space of the one in parenthesis, don't just guess :P


--- Solution


local Main; -- Don't touch
for i, v in pairs(ThatModelYouWant:GetChildren())
if (not Main) then
Main = v
else
local Weld = Instance.new("Weld",game.JointsService)
Weld.C1 = v.CFrame:toObjectSpace(Main.CFrame);
Weld.Part0 = Main
Weld.Part1 = v
end
end
Report Abuse
amanda is not online. amanda
Joined: 21 Nov 2006
Total Posts: 5925
17 Mar 2015 07:44 PM
DrMathematica, thanks so much.
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
17 Mar 2015 07:47 PM
Nooooo problem :P
Report Abuse
kert109 is not online. kert109
Joined: 31 Dec 2009
Total Posts: 681
17 Mar 2015 08:01 PM
"
Weld.C1 = v.CFrame:toObjectSpace(Main.CFrame);
Weld.Part0 = Main
Weld.Part1 = v
"

Amg, I just remembered I had this problem last time and that's how I fixed.

And who defines "bad practice" of using C0?
Report Abuse
DrMathematica is not online. DrMathematica
Joined: 29 Aug 2008
Total Posts: 27268
17 Mar 2015 08:04 PM
"And who defines "bad practice" of using C0?"

It's logically viewed as bad practice because it serves a key point in other joint objects such as Rotates (hinges, motors, stepping motors). Why? Ever tried making an NPC with Motors or Motor6Ds?

You can't rely solely on C0 to do it, because you need that to create a center point for pivotal swinging, while C1 will be used to offset Part1.

Don't reply with "Well it doesn't matter in this case" because I've heard that a thousand times. It's true, it doesn't, but it's bad practice to misuse a property. Doesn't mean it's wrong.
Report Abuse
kingkiller1000 is not online. kingkiller1000
Joined: 12 Dec 2008
Total Posts: 26415
17 Mar 2015 08:10 PM
It's usually easiest to keep C0 as CFrame.new() and use only C1 except for certain cases with motors. Since joints on Roblox have Part0 follow Part1, it makes more sense to set C1 so that you're calculating relative to Part1 rather than Part0.
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