Armor help, not working. Using :toObjectSpace

This is the code:

--//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

For some reason this doesn’t work, so I don’t wear the armour, but I am connected it to it, because I get weird Collisions when I have it equipped. The armour has cancollide off, and anchor off. So Any help would be appreciated. Thank you.

I’m not sure why this doesn’t work. The armor doesnt get equipped.

1 Like

I’ve also tried SelectedArmorPiece.CFrame:inverse() * playerBodyPart.CFrame
and vice versa, I’ve tried welding different parts and can’t seem get it to work.

I still haven’t been able to make this work, I took a break for a little bit, and when I can back I still couldn’t figure it out. Please if anyone does read this, and knows what I am doing wrong please let me know. Thank you.

Maybe the armor parts aren’t all getting welded together properly?

How would I know?

I’ve checked the weld:

image

Also, I think I fixed the part where it gets added to character. but it’s not sideways:
image

I’d recommend using Humanoid:AddAccessory() Where all you do is put in a joint into the piece of armor, calling the brick holding the entire thing handle and welding all the bricks to it. Then you could just use 1 line of code to apply armor to the character easily.

Could explain more about this please, or link to a video or documentation of it. Thank you.

So here we have the armor piece, it can have anything that you want. In order for everything to work here though you need to weld everything to each other. In order to do this you can use a plugin rather than a script because the script will just lag the game.

https://gyazo.com/961bd3bb70c39f669e5df4032081365a

Then once you got your armor you should group it to separate it from the part from which we will be welding like here: You see a Torso joint so this means when we run the command it will know that we want to apply this to the torso rather than any other part of the body. You can move it up,down and sideways to offset the armor to your needed position and as well rotate it.

https://gyazo.com/75d1785df1d9c0d20510304021ba2e8c

Make sure to name it Handle or else it wont work and weld it to other parts in the now made model of other armor pieces we made. Make sure all the parts, including the handle aren’t anchored and have CanCollide set to false and move it to Lighting or where ever your armor is.

Now to test if it works, instead of me writing a script ill just give you an example of a line you’d use to apply the armor:
https://gyazo.com/10ecd04a5e59fbee13045ab2fad61ab9

In the brackets you put the location of the dedicated armor piece and it’s name. It can be called anything. If you are using this in gameplay style then you want to to something like :AddAccessory(game.Lighting.Torso:Clone()) To make sure that next time if you want to apply it after death that it’s still there to be used.

Make sure that the Handle and the Model are inside of an accessory and that Handle is directly child of the accessory if it’s in the model with other parts it won’t work!

In the end after running the command we end up with this.

https://gyazo.com/e09e277ddd41c9c3ad6a2ad1c8996e6e

More on this here: Humanoid | Documentation - Roblox Creator Hub
And make sure to run this from a server script or it wont work.

1 Like

Thank you so much, I really appreciate it.

1 Like

I have read everything you have said, Also looked at the developer doc. So I have something like this:

image
Character is R15. I put this on my character and it just falls straight through the world. Do I have to add more attachments the same as the R15 or should this just work.

Anchored and can collide is false.

When I run the game it stays on the dummy;
image
but when I add it to my character it just falls.

You have to weld everything to the Handle part

So I have a handle part, which lets say is the torso, I’ll have to weld the arm, legs and head to it?

No Handle is suppose to be the part where the joint is going to be put, its not the character torso

I’m confused, so what is the handle? Is it a invisible part? Sorry, I don’t quite understand. Right now, the handle is the armor piece.

Handle should be an invisible piece which contains the joint and it must be child of the accessory not in any models

So this is what I currently have.
image
and it still doesn’t work It goes through the ground, I am adding to the character through server.

Edit: I got it to work, I know what I did wrong.

Are all of the parts welded to Handle?