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

Why does my weld script not attach the part to characters head?

I am trying to weld a cap onto my custom characters head through a clothing GUI but it doesnt work. Why?

game.ReplicatedStorage.Events.HatEvent1.OnServerEvent:Connect(function(plr)
	local char = plr.Character
	local Storage = game.ReplicatedStorage.Hats.Cap1
	local Head = char.Head
	local New_Cap1 = Storage:Clone()
	
	
	
	New_Cap1.Parent = Head
	local Weld = Instance.new("Weld")
	
	Weld.Parent = New_Cap1
	
	Weld.Part0,Weld.Part1 = Head, New_Cap1
	Weld.C0 = CFrame.new (0,0.6,0)
	Weld.C1 = Head.CFrame
	
	
	
	
		
		
	
end)

2 answers

✓ Accepted answer

Hello,

Upon looking at your script, I find the most glaring issue to be the fact that you are never setting a parent for New_Cap1.

While clones do retain most of the information from the Instance they are cloned from, they do not retain the Parent property.

You must give it a parent for the object to be able to be welded!

1 comment

0

Ok, It attaches but not on my head.

Found It. Check out this video he explains it better than I can : https://www.youtube.com/watch?v=LEy0po6sLso&t=839s

game.ReplicatedStorage.Events.HatEvent1.OnServerEvent:Connect(function(plr)
	local char = plr.Character
	local Storage = game.ReplicatedStorage.Hats.Cap1
	local Head = char.Head
	local New_Cap1 = Storage:Clone()
	
	
	New_Cap1.CFrame = Head.CFrame * CFrame.new(0,2,0)
	New_Cap1.Parent = Head
	local Weld = Instance.new("Weld")
	
	Weld.Parent = New_Cap1
	
	Weld.Part0,Weld.Part1 = Head, New_Cap1
	Weld.C0 = New_Cap1.CFrame:Inverse()
	Weld.C1 = Head.CFrame:Inverse()
	
	
	
	
		
		
	
end)

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