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
8 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.

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(chr)
        local part = Instance.new("Part", game.Workspace)
        part.BrickColor = BrickColor.new("Really red")
        part.Size = Vector3.new(2, 2, 2)
        part.Name = "Welded part"
        local weld = Instance.new("Weld", chr)
        weld.Part0 = part
        weld.Part1 = chr.Torso
        weld.C0 = CFrame.new()
        weld.C1 = CFrame.new()
    end)
end)

1 answer

Log in to vote
0
Answered by 8 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.

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(chr)
        local part = Instance.new("Part", game.Workspace)
        part.BrickColor = BrickColor.new("Really red")
        part.Size = Vector3.new(2, 2, 2)
        part.Name = "Welded part"

    -- This should suffice
    char:WaitForChild( "Torso" )

    -- Change the parent to part
        local weld = Instance.new( "Weld",  part )
        weld.Part0 = part
        weld.Part1 = chr.Torso

    -- No need to set the C0, it's already a empty CFrame by default
        -- weld.C0 = CFrame.new()
    end)
end)
Ad

Answer this question