Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Welding won't work?

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.