Armor Welds Not Working Properly On The Characters Legs

  1. I want to make a module script that can easily remove / equip custom armor models for a RPG game.

  2. The problem is everything works fine but sometimes the legs in the armor model don’t weld to the character and sometimes it does. Also there are no error messages

  3. I have tried changing the orientations of the parts in the armor model and changing whether they weld to the lower or upper leg parts in the character but it only works on certain models.

My Server Script

local Module = require(game.ReplicatedStorage.ArmorModule) -- Require Module
-- Replicated Storage
local rs = game.ReplicatedStorage or game:GetService("ReplicatedStorage")

game.Players.PlayerAdded:Connect(function(plr) -- When Player Joins
	local char = plr.Character or plr.CharacterAdded:Wait()
	-- The Armor Is In rs.ARMORS
	Module:MakeArmor(char, rs.ARMORS:FindFirstChild('Steel')) -- The legs on this don't weld
	Module:MakeArmor(char, rs.ARMORS:FindFirstChild('Bone')) -- The legs on this weld fine

My Module Script

local ArmorModule = {} -- Module Name
--Remove old armour.

function ArmorModule.RemoveArmor(character)
	-- Search Through Character For The Names Of Armors
	for i,v in pairs(character:GetChildren()) do
		if not v:IsA("BasePart") and v:IsA("Model") then -- Makes Sure That Only Armor Models Are Deleted
			if v.Name == "LeftUpperArm" then
			elseif v.Name == "LeftLowerArm" then
			elseif v.Name == "RightUpperArm" then
			elseif v.Name == "RightLowerArm" then
			elseif v.Name == "UpperTorso" then
			elseif v.Name == "LowerTorso" then
			elseif v.Name == "LeftUpperLeg" then
			elseif v.Name == "LeftLowerLeg" then
			elseif v.Name == "RightUpperLeg" then
			elseif v.Name == "RightLowerLeg" then

local removearmor = ArmorModule.RemoveArmor

function ArmorModule:MakeArmor(character, armor)
	removearmor(character) -- Removes the already equipped armor
	local armorpart = armor:Clone()
	-- Searches through the main armor model
	for a, b in pairs(armorpart:GetChildren()) do
		print(b.Name) -- This prints
		-- Seaches through the model parts
		for i,v in pairs(b:GetChildren()) do
			print(v.Name) -- This prints
			v.Anchored = false
			v.CanCollide = false
			if v.Name == 'Middle' then 
				v.Transparency = 1
				-- Weldy Things
				local Y ="Weld")
				Y.Part0 = character[b.Name]
				Y.Part1 = b.Middle
				Y.C0 =, 0, 0)
				Y.Parent = Y.Part0
				-- More Weldy Things
				local W ="Weld")
				W.Part0 = b.Middle
				W.Part1 = v
				local CJ =
				local C0 = b.Middle.CFrame:inverse()*CJ
				local C1 = v.CFrame:inverse()*CJ
				W.C0 = C0
				W.C1 = C1
				W.Parent = b.Middle
		--Parents The Finished Armor Model
		b.Parent = character

return ArmorModule

If You Need The Armor Folder With The Armor Models (It only works on the Bone armor and not the Steel armor however when I remove the meshes from the Bone armor the legs don’t work)

If I made any mistakes in the code or if its not optimized then do tell me. Any example scripts would be greatly appreciated and thanks for the help in advance. :grinning:

1 Like

Don’t use :Remove() in your code. It won’t cause problems to my knowledge, but :Remove() is deprecated and :Destroy() should be used in favor of it.

1 Like

It will, depending on the instance in question. Remove just reparents an object to nil. Destroy will destroy all connections, lock the object and parent it to nil. It is also recursively called upon all descendants. Destroy readies up an instance for garbage collection, remove just reparents. You are more likely to encounter a memory leak by using remove due to hanging instances.