Wear accessory through script

I wanna know how would i make a script that would get a certain accessory and then let the player wear it ive already tried something like this

equip.MouseButton1Down:Connect(function()
print('player clicked')
local insertService = game:GetService('InsertService')
local accsesory = insertService:LoadAsset(fifthAssetId).Parent = player
end)

this puts the accessory in the players character though its not actually wearing it

1 Like

Get the model by using LoadAsset, extract the Accessory then AddAccessory to the player’s Humanoid, like this:

local theAccessoryID = 12770588685

local insertService = game:GetService('InsertService')

script.Parent:WaitForChild("ClickDetector").MouseClick:Connect(function(plr) -- lets say this is a part in workspace with this script in it and a ClickDetector to work as a button
	print('player clicked')
	local model = insertService:LoadAsset(theAccessoryID) -- get the model
	local Accessory = model:FindFirstChildWhichIsA("Accessory") -- extract the accessory
	plr.Character.Humanoid:AddAccessory(Accessory) -- add the accessory to the player
	model:Destroy() -- clear the previous loaded model
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.