How would I add an accessory to a cloned players through a GUI button?

Hello, I’m currently working on a character customization menu for my RPG project. How it works right now is through a LocalScript a cloned version of the player’s character will appear in the menu.

I have two sets of ears in ReplicatedStorage at the moment one for when a person clicks the ElfButton and one for some clicks the GoblinButton both ears also have the proper attachments needed in order to add to the player’s Humanoid.
image

I’m currently using a LocalScript for the Menu and a SeverScript for the player’s actual Character.

Here’s what I have so far for the LocalScript whenever someone would press the elf button

ElfButton.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Events.ElfEvent:FireServer()
	SkinTone:TweenPosition(UDim2.new(1.509, 0,0.759, 0), "Out", "Sine", 1, false)
	local SkinTone1 = BrickColor.new("Pastel brown")
	local ClotheTone = BrickColor.new("Black") -- Clothing to avoid looking naked 
	ClonedCharacter.Head.BrickColor = SkinTone1
	ClonedCharacter["Left Arm"].BrickColor = SkinTone1
	ClonedCharacter["Left Leg"].BrickColor = ClotheTone
	ClonedCharacter["Right Arm"].BrickColor = SkinTone1
	ClonedCharacter["Right Leg"].BrickColor = ClotheTone
	ClonedCharacter.Torso.BrickColor = ClotheTone

end)

and here’s what happens so far in the SeverScript whenever the Event from the LocalScript is fired:

game.ReplicatedStorage.Events.ElfEvent.OnServerEvent:Connect(function(player)
	local HumanButton = game.StarterGui.PlayerUI.CharacterMenu.Elf
	local Character = player.Character
	local SkinTone1 = BrickColor.new("Pastel brown")
	local ClotheTone = BrickColor.new("Black") -- Clothing to avoid looking naked 

	Character.Head.BrickColor = SkinTone1
	Character["Left Arm"].BrickColor = SkinTone1
	Character["Left Leg"].BrickColor = ClotheTone
	Character["Right Arm"].BrickColor = SkinTone1
	Character["Right Leg"].BrickColor = ClotheTone
	Character.Torso.BrickColor = ClotheTone

end)

Anything about how I would add the ears or destroy the ears on the player’s character (for whatever button they click respectively) will be great to know.

Can’t you just copy and paste the accessory from replicatedstorage to the character or am i not understanding your question correctly?

Well yeah cloning the accessory, but I was talking about adding the accessory to the player’s head once the function is fired. I look into using :AddAccessory() but it didn’t work.

well you can just copy it from replicated storage and pasting it into the character model

I manage to make the SeverScript work, it now just seems to be a local script issue. This is what I currently have for the function when someone clicks the ElfButton:

ElfButton.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.Events.ElfEvent:FireServer()
	SkinTone:TweenPosition(UDim2.new(1.509, 0,0.759, 0), "Out", "Sine", 1, false)
	local SkinTone1 = BrickColor.new("Pastel brown")
	local ClotheTone = BrickColor.new("Black") -- Clothing to avoid looking naked 
	ClonedCharacter.Head.BrickColor = SkinTone1
	ClonedCharacter["Left Arm"].BrickColor = SkinTone1
	ClonedCharacter["Left Leg"].BrickColor = ClotheTone
	ClonedCharacter["Right Arm"].BrickColor = SkinTone1
	ClonedCharacter["Right Leg"].BrickColor = ClotheTone
	ClonedCharacter.Torso.BrickColor = ClotheTone
	ClonedCharacter.Humanoid:AddAccessory(ElfEarsClone)
	if ClonedCharacter:FindFirstChild("GoblinEars") ~= nil then
		ClonedCharacter.GoblinEarsClone:Destroy()
	end
end)```
1 Like