:ToObjectSpace Not working? Read Replies!

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:

image

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.

I’m not sure if it’s working :sweat_smile: bc didnt test it, but try something like this:

local RS = game:GetService("ReplicatedStorage")
local ArmorModel = RS.Armour.ArmorTest

Armor = {
	
ArmorModel.ChestPiece,
ArmorModel.Helmet,
ArmorModel.LeftArmShoulder,
ArmorModel.LeftLegPad,
ArmorModel.RightArmShoulder,
ArmorModel.RightLegPad
}

Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
	for i = 1, #Armor do
		local SelectedArmour = Armor[i]:Clone()
	if SelectedArmour.Name == "ChestPiece" then
		BodyPart = char.UpperTorso
	elseif SelectedArmour.Name == "Helmet" then
		BodyPart = char.Head
	--add more(im lazy)
	end
	SelectedArmour.Parent = char
	local weld = Instance.new("Weld", char)
	weld.Name = SelectedArmour.Name
	weld.Part0 = BodyPart
	weld.Part1 =  SelectedArmour 
		end
	end)
end)
1 Like

Tested it and It didn’t work. Not sure why.

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)

No errors.

Try again, I edited

((EDITED MORE…))

30

It works, but it’s side ways:
image

You need to edit C0 and C1 of Weld.

How would I add it, weld.C0 = [Not sure what to add here]

CFrame.new(0,0,0) * CFrame.Angles(0,0,0) --position and angles

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