I am trying to weld a part to a player's torso when they join the game, but all it does is creates the part and the part sits on the baseplate.
01 | game.Players.PlayerAdded:connect( function (plr) |
02 | plr.CharacterAdded:connect( function (chr) |
03 | local part = Instance.new( "Part" , game.Workspace) |
04 | part.BrickColor = BrickColor.new( "Really red" ) |
05 | part.Size = Vector 3. new( 2 , 2 , 2 ) |
06 | part.Name = "Welded part" |
07 | local weld = Instance.new( "Weld" , chr) |
08 | weld.Part 0 = part |
09 | weld.Part 1 = chr.Torso |
10 | weld.C 0 = CFrame.new() |
11 | weld.C 1 = CFrame.new() |
12 | end ) |
13 | end ) |
I think that might happen because torso itself isn't properly created yet, so you might want the script to wait for a bit before you weld anything.
Also, I think the weld should be inside the Part0, or it might not work. Can't confirm for sure though.
01 | game.Players.PlayerAdded:connect( function (plr) |
02 | plr.CharacterAdded:connect( function (chr) |
03 | local part = Instance.new( "Part" , game.Workspace) |
04 | part.BrickColor = BrickColor.new( "Really red" ) |
05 | part.Size = Vector 3. new( 2 , 2 , 2 ) |
06 | part.Name = "Welded part" |
07 |
08 | -- This should suffice |
09 | char:WaitForChild( "Torso" ) |
10 |
11 | -- Change the parent to part |
12 | local weld = Instance.new( "Weld" , part ) |
13 | weld.Part 0 = part |
14 | weld.Part 1 = chr.Torso |
15 |
16 | -- No need to set the C0, it's already a empty CFrame by default |
17 | -- weld.C0 = CFrame.new() |
18 | end ) |
19 | end ) |