Hello, so I'm welding a model to a character and having difficulty. The model I weld either works perfectly or sometimes, inexplicably, will just fail to weld properly. It will appear for half a second and then, unanchored, will fall through the world and destroy itself as if the weld is non existant.
After some testing I've narrowed it down to this; the weld is just not appearing in the model properly SOMETIMES and other times it works fine.
I've used 'repeat wait until() weld exists in the right place' to try and fix this but then it just waits infinitely. This is the script I use, I really hope someone can point out what I'm doing wrong to try and get this working 100% of the time.
local Event = game.ReplicatedStorage.AccessoryEvents:WaitForChild('HeadAccessory')
local function OnEventFired(player, detail)
if detail == 'accessoryA' then
local Accessory = game.ReplicatedStorage.Accessories.Head.Hat:Clone()
local g = Accessory:Clone()
g.Parent = player.Character
local C = g:GetChildren()
for i=1, #C do
if C[i]:IsA("BasePart") then
local W = Instance.new("Weld")
W.Part0 = g.Middle
W.Part1 = C[i]
local CJ = CFrame.new(g.Middle.Position)
local C0 = g.Middle.CFrame:inverse()*CJ
local C1 = C[i].CFrame:inverse()*CJ
W.C0 = C0
W.C1 = C1
W.Parent = g.Middle
end
local Y = Instance.new("Weld")
Y.Part0 = player.Character.Head
Y.Part1 = g.Middle
Y.C0 = CFrame.new(0, 0, 0)
Y.Parent = Y.Part0
C[i].CanCollide = false
C[i].Anchored = false
end
end
end
Event.OnServerEvent:Connect(OnEventFired)
I wonder if there is some property of welds I'm missing that means they can't fix properly while the character is moving sometimes or what, it breaks usually after the character has moved for the first time and is then standing still.

2 comments
confusing script for me, can't help
Okay?