I have this script that should cycle through a list of body parts (In a rather clunky manner) And weld a set of parts to the specified body part. However, When the script is activated, Nothing Happened
local OB = PlayerAttire:WaitForChild("OutfitBottom")
Previously, this line used FindFirstChild which resulted in OB coming back as nil. OutfitBottom is a StringValue within a folder named Outfit.
Sorry for the gross code at the bottom, I'm gonna put that list of body parts into a table or something. Thanks for any help!
wait(.1) local player while not player do wait() player = game:GetService('Players').LocalPlayer end local PE = Instance.new("Model") PE.Name = ("PlayerEquipment") function weld(p1,p2,c0) local w = Instance.new("Weld",p1) w.Part0 = p1 w.Part1 = p2 w.C0 = c0 or p1.CFrame:inverse() * p2.CFrame return w end local PD = player.PlayerGui:FindFirstChild("PlayerData") local PlayerAttire = PD:FindFirstChild("Outfit") local WD = PD:FindFirstChild("WeldData") local Weldee = PD.Weldee function PerformWeld() local Outfit = game.Lighting.OutfitStorage:FindFirstChild(Weldee.Value):Clone() local char = player.Character or player.CharacterAdded:wait() local CurrentSection = Outfit:FindFirstChild(WD.Value.."Components"):Clone() CurrentSection.Parent = char for _,v in pairs(CurrentSection:GetChildren()) do if v.ClassName == "Part" or v.ClassName == "UnionOperation" then v.Anchored = true end end CurrentSection.Parent = PE for _,v in pairs(CurrentSection:GetChildren()) do if v.ClassName == "Part" or v.ClassName == "UnionOperation" then if v ~= CurrentSection["ArmorCore"] then weld(v, CurrentSection["ArmorCore"]) end end end local CurrentSectionWeld = weld(CurrentSection["ArmorCore"], char[WD.Value], CFrame.new()) for _,v in pairs(CurrentSection:GetChildren()) do if v.ClassName == "Part" or v.ClassName == "UnionOperation" then v.Anchored = false v.CanCollide = false end end end function SetOutfit() local OB = PlayerAttire:WaitForChild("OutfitBottom") local OT = PlayerAttire:WaitForChild("OutfitTop") OB.Value = ("Standard Military Platelegs") OT.Value = ("Standard Military Platebody") player.PlayerGui.TeamAButton:Destroy() player.PlayerGui.TeamBButton:Destroy() end SetOutfit() wait(0.5) PE.Parent = player.Character local SP = game.Lighting.SwordPlaySystemMK2:Clone() SP.Parent = player.PlayerGui SP.Disabled = false local OT = PlayerAttire:FindFirstChild("OutfitTop") Weldee.value = OT.Value WD.Value = ("Chest") PerformWeld() wait(0.1) WD.Value = ("Torso") PerformWeld() wait(0.1) WD.Value = ("Pelvis") PerformWeld() wait(0.1) WD.Value = ("LeftArm") PerformWeld() wait(0.1) WD.Value = ("RightArm") PerformWeld() wait(0.1) WD.Value = ("LeftForearm") PerformWeld() wait(0.1) WD.Value = ("RightForearm") PerformWeld() wait(0.1) WD.Value = ("LeftElbow") PerformWeld() wait(0.1) WD.Value = ("RightElbow") PerformWeld() wait(0.1) WD.Value = ("LeftShoulder") PerformWeld() wait(0.1) WD.Value = ("RightShoulder") PerformWeld() wait(0.1) WD.Value = ("RightHand") PerformWeld() wait(0.1) WD.Value = ("LeftHand") PerformWeld() wait(0.1) Weldee.value = PlayerAttire.OutfitBottom.Value WD.Value = ("LeftThigh") PerformWeld() wait(0.1) WD.Value = ("LeftCalf") PerformWeld() wait(0.1) WD.Value = ("LeftKnee") PerformWeld() wait(0.1) WD.Value = ("LeftFoot") PerformWeld() wait(0.1) WD.Value = ("Pelvis") PerformWeld() wait(0.1) WD.Value = ("RighttThigh") PerformWeld() wait(0.1) WD.Value = ("RightCalf") PerformWeld() wait(0.1) WD.Value = ("RightKnee") PerformWeld() wait(0.1) WD.Value = ("RightFoot") PerformWeld() wait(0.1)