Accesseory Giver not working

local Armor = game.ReplicatedStorage.Storage.Berets.JTF2
Armor.PrimaryPart = Armor.Beret:WaitForChild("Head")
local ProximityPrompt = script.Parent


--/Welds
function WeldParts(part0,part1)
	local newWeld = Instance.new("Weld")
	newWeld.Part0 = part0
	newWeld.Part1 = part1
	newWeld.C0 = CFrame.new()
	newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)
	newWeld.Parent = part0
end


--//Main Function
ProximityPrompt.Triggered:Connect(function(Player)
	local Character = Player.Character
	local Helmet = Character:WaitForChild("Head")
	ProximityPrompt.ActionText = "Wear"
	if Character:FindFirstChild(script.Parent.Parent.Parent.Name) then
		Character[script.Parent.Parent.Parent.Name]:Destroy()
	else
		--Below is the hat remover (Optional: Delete this)
	--[[	local d = Player.Character:GetChildren()
		for i=1, #d do 
			if d[i]:IsA("Accessory") then
				d[i]:Destroy()
			end 
		end ]]
		--Above is the hat remover (Optional: Delete this)
		local NewArmor = Armor:Clone()
		NewArmor:SetPrimaryPartCFrame(Helmet.CFrame)
		NewArmor.PrimaryPart:Destroy()
		ProximityPrompt.ActionText = "Wear"
		for _, part in pairs (NewArmor:GetChildren()) do
			if part:IsA("BasePart") then
				WeldParts(Helmet, part)
				part.CanCollide = false
				part.Anchored = false
			end
		end
		NewArmor.Parent = Character
	end
end)

“JTF2” is an accesseory. Below is a model called Beret, and under that model has a few parts. One is called head. It won’t work at all. Error is "PrimaryPart is not a valid member of Accesseory “JTF2"”
I understand Accesseories can’t have primaryparts, but is there an alternative?

i dont think theren is a alternive

If your just equipping it why not just use Humanoid:AddAccessory()

Humanoid:AddAccessory.

1 Like

i didnt know Humanoid:AddAccessory() existed

The more you know :smile: I use it for equippable items that give HP in my rpg game

1 Like

ok thanks this might be useful for scripting later on

Whoa LOL. I didn’t know. I’ll try this. Roblox text limit filling…

I thought everyone used it, I kind of taught myself using dev hub and accessory experimination

1 Like

If it works can you give me solution thingy?

1 Like

AddAcesseory automatically clones right?

It doesn’t clone, what I would suggest is something like

local THEACCESSORY = game.ReplicatedStorage.Hat:Clone()

Humanoid:AddAccessory(THEACCESSORY)


and for unequip do:

THEACCESSORY:Destroy()

2 Likes

Post must be be at least 30 words, Have you tried the :growing_heart: Button

2 Likes

For me it’s 30… Why though?.. Is it my rank too low?

forgot to multiply by 2

ROBLOX KEEPS SAYING:

Post must be at least 30 words Have you tried the :heartpulse: Button

(Cant say characters because roblox dosent allow that)

It worked, but it won’t like, weld to the character.

local Armor = game.ReplicatedStorage.Storage.Berets.JTF2
local PrimaryPart = Armor.Beret:WaitForChild("Head")
local ProximityPrompt = script.Parent


--/Welds
function WeldParts(part0,part1)
	local newWeld = Instance.new("Weld")
	newWeld.Part0 = part0
	newWeld.Part1 = part1
	newWeld.C0 = CFrame.new()
	newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)
	newWeld.Parent = part0
end


--//Main Function
ProximityPrompt.Triggered:Connect(function(Player)
	local Character = Player.Character
	local Humanoid = Player.Character.Humanoid
	local Helmet = Character:WaitForChild("Head")
	ProximityPrompt.ActionText = "Wear"
	local NewArmour = Armor:Clone()
	Character.Humanoid:AddAccessory(NewArmour)
	for _, part in pairs (NewArmour:GetChildren()) do
		if part:IsA("BasePart") then
			WeldParts(Helmet, part)
		end
	end
	
local Armor = game.ReplicatedStorage.Storage.Berets.JTF2
local PrimaryPart = Armor:WaitForChild("Head")
local ProximityPrompt = script.Parent


--/Welds
function WeldParts(part0,part1)
	local newWeld = Instance.new("Weld")
	newWeld.Part0 = part0
	newWeld.Part1 = part1
	newWeld.C0 = CFrame.new()
	newWeld.C1 = part1.CFrame:toObjectSpace(part0.CFrame)
	newWeld.Parent = part0
end


--//Main Function
ProximityPrompt.Triggered:Connect(function(Player)
	local Character = Player.Character
	local Humanoid = Player.Character.Humanoid
	local Helmet = Character:WaitForChild("Head")
	ProximityPrompt.ActionText = "Wear"
	local NewArmour = Armor:Clone()
	
	for _, part in pairs (NewArmour:GetChildren()) do
		if part:IsA("BasePart") then	
			NewArmour:SetPrimaryPartCFrame(Helmet.CFrame)
			WeldParts(Helmet, part)
			part.CanCollide = false
			part.Anchored = false
		end
	end
	Character.Humanoid:AddAccessory(NewArmour)
end)

Won’t even clone…

You have to name the part inside Handle

1 Like

Which part do I name ‘Handle’? There’s like 4 parts.

The part you want on your head and then weld the other parts together