Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Using AddAccessory to place hat on character?

I believe I'm using AddAccessory correctly, but it keeps showing a scripting error that is "AddAccessory is not a valid member of Model." blondebun is an accessory class item, but it is stored in the meshes group in lighting anyway. Here's my code:

function click()
	local accessory = game.Lighting.meshes.blondebun:Clone()
	local player = game.Players.LocalPlayer
	local playercharacter = game.Players.LocalPlayer.Character
	local playername = player.Name
	local humanoid = game.Workspace:FindFirstChild(playername)
	
	playercharacter:AddAccessory(accessory)
end

script.Parent.MouseButton1Click:connect(click)

2 comments

0

you could just do accessory.Parent = playercharacter. This might be easier than doing what your trying to do.

0

It works in studio. I'll see if it works in the actual game - thanks so much for the advice!

1 answer

First off, :AddAccessory() is a function of the character's Humanoid, not the Character Model. Second, I'm pretty sure Humanoid:AddAccessory() is no longer working as I've been trying to get it to work for about a day or two, and the only thing I got was the accessory spawning in the game's origin location. Maybe try "accessory.Parent = characterModel" like Nikkulaos suggested in comments? Haven't tried it, but I'm pretty sure it'll work.

This discussion is preserved as it was. New answers, comments, and votes are closed.