Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Welding won't work?

Asked by
Spoookd 32
9 years ago

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.

01game.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 = Vector3.new(2, 2, 2)
06        part.Name = "Welded part"
07        local weld = Instance.new("Weld", chr)
08        weld.Part0 = part
09        weld.Part1 = chr.Torso
10        weld.C0 = CFrame.new()
11        weld.C1 = CFrame.new()
12    end)
13end)

1 answer

Log in to vote
0
Answered by 9 years ago

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.

01game.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 = Vector3.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.Part0 = part
14        weld.Part1 = 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)
19end)
Ad

Answer this question