So I have looked at many different forums and different videos, and I can’t seem to figure out how to make armor, So my Current layout is like this:
So I have this as test armor, and how would I go about putting this on the character. I know I will have to use welds, but not sure how to do this.
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
for i = 1, #Armor do
local SelectedArmour = Armor.ChestPiece
local weld = Instance.new("Weld")
local playerBodyPart = char.UpperTorso
weld.C0 = CFrame.new(0, 0, 0)
weld.C1 = SelectedArmor.CFrame
weld.Part0 = playerBodyPart
weld.Part1 = SelectedArmor
weld.Parent = SelectedArmor
SelectedArmor.Parent = char.UpperTorso
end
end)
end)
This is what I currently have, This doesn’t work, but It’s really inefficient since it’s only doing a chestPiece and not everything, although I have put this in a for loop how would I make user It applies to all parts of the body.
Any help would be appreciated. Any videos, documents that could help please let me know. Thank you.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Armour = ReplicatedStorage:WaitForChild("Armour"):WaitForChild("ArmorTest")
local Players = game:GetService("Players")
Armor = {
Armour.ChestPiece,
Armour.Helmet,
Armour.LeftArmShoulder,
Armour.LeftLegPad,
Armour.RightArmShoulder,
Armour.RightLegPad
}
Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
for i = 1, #Armor do
local SelectedArmour = Armor[i]
if SelectedArmour.Name == "ChestPiece" then
local BodyPart = char.UpperTorso
elseif SelectedArmour.Name == "Helmet" then
local BodyPart = char.Head
--add more(im lazy)
end
local Weld = Instance.new("Weld", char)
Weld.Name = SelectedArmour.Name
Weld.Part0 = BodyPart
Weld.Part1 = SelectedArmour
end
end)
end)
Sorry this took a while for me to understand, not I tried using :ToObjectSpace and it doesn’t work, it just doesn’t go on the character: How would I fix this, I believe the :ToObjectSpace Should work.
--//Armour
for i, v in pairs(Armour.ArmourTable) do
if item == v.Name then
if state == "Equip" then
-- EquipArmour
local char = player.Character -- Gets Players Character
local currentArmorFolder = char:FindFirstChild('Armor') -- Get's CurrentArmorFolder
if not currentArmorFolder then -- If there isn't one then it will make one
currentArmorFolder = Instance.new('Folder')
currentArmorFolder.Name = 'Armor'
currentArmorFolder.Parent = char
end
local currentArmor = currentArmorFolder:GetChildren() -- Gets Current Armor
local newArmor = bp:Clone() -- Clones armor
local children = newArmor:GetChildren() -- Gets the Children of Armor
for i = 1, #children do -- For loop through all items in the armor
local SelectedArmorPiece = children[i]
if SelectedArmorPiece:IsA("Configuration") then -- If it is a folder then Ignore
-- Do nothing, Ignore it
else
local weld = Instance.new("Weld")
local playerBodyPart = char:FindFirstChild(SelectedArmorPiece.Name) -- getting the armour name and the players limb name, so arm and arm
weld.C0 = SelectedArmorPiece.CFrame:ToObjectSpace(playerBodyPart.CFrame) -- This may be the issue
weld.Part0 = playerBodyPart
weld.Part1 = SelectedArmorPiece
weld.Parent = SelectedArmorPiece
SelectedArmorPiece.Parent = char.Armor
end
end
Update.UpdateArmor(player, serial)
elseif state == "UnEquip" then
Update.UpdateArmor(player, 0)
-- // need to unequip
local currentArmorFolder = char:FindFirstChild('Armor')
local currentArmor = currentArmorFolder:GetChildren()
if #currentArmor > 0 then
for i = 1, #currentArmor do
local selectedPart = currentArmor[i]
selectedPart:Destroy()
end
end
end
end
end