So I am trying to make armor loadouts when you spawn in and I am trying to start learning by first making it to where I can use PlayerAdded to weld the vests to the characters. The problem is, is that when I spawn in, the model's parts are everywhere and I can't seem to fix it. So far it worked when I used it for testing with Touched functions.
So far the issue seems to lie in the part where I return the vest accessories to the middle part but so far in this new code, all accessories have instead gone all over the place.
game.Players.PlayerAdded:Connect(function(hit) hit.CharacterAdded:wait() wait() if hit.Character:findFirstChild("Humanoid") ~= nil and hit.Character:findFirstChild("Chest") == nil then local g = game.ReplicatedStorage.Chest:clone() g.Parent = hit.Character local C = g:GetChildren() for i=1, #C do if C[i].className == "Part" or C[i].className == "UnionOperation" or C[i].className == "MeshPart" 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.C0 = C1 W.Parent = g.Middle end local Y = Instance.new("Weld") Y.Part0 = hit.Character.UpperTorso Y.Part1 = g.Middle Y.C0 = CFrame.new(0, 0.2, 0) Y.Parent = Y.Part0 end local h = g:GetChildren() for i = 1, # h do h[i].Anchored = false h[i].CanCollide = false end end
end)