Use tool to AddAccessory not working as expected

Hi there!..

I’m just in the beginning stages of testing out some ideas/working on understanding some basics…

For this one I’m trying to figure out how to add a basic accessory using a Local Script, via a Tool (Essentially using a Tool to house the script to add the accessory). I see the hat show up in front of my character and ultimately fall out of the world when testing with the Tool…

If I run a test and just drop the hat onto my character manually (drag from ReplicatedStorage) it works just fine…

local PlayersService = game:GetService("Players")
local LocalPlayer = PlayersService.LocalPlayer
local Character = ((LocalPlayer.Character and LocalPlayer.Character.Parent) and LocalPlayer.Character) or LocalPlayer.CharacterAdded:Wait()
local Humanoid = Character:WaitForChild("Humanoid")
local Tool = LocalPlayer.Backpack:FindFirstChild("HatTestTool")
local hat

Tool.Equipped:Connect(function(mouse)
	hat = game.ReplicatedStorage.HatTest:Clone()
	print("After hat declaration, hat is: ",hat)
	Humanoid:AddAccessory(hat)
end)

accessory tool

probably because you are equipping it on the client and not on the server which would mean the server doesnt handle the physics and welding of the hat to the character. Trying using a remote event that equips it on the server. This may not work but try it out.

It doesn’t work as server storage cannot be viewed or accessed by the client, try to put the hat in the replicated storage. Hopefully it helps!

If you have a quick look at the code and attached image, the Accessory is already located in Replicated Storage…

I’ll give that a try as soon as I’m able… thx!

no problem, just be sure to mark my post as the solution if it works :grin: trying to grind for that regular promotion lol

I have an idea! First try to parent it to the player’s character and see what happens:

 Tool.Equipped:Connect(function()
 	hat = game.ReplicatedStorage.HatTest:Clone()
    hat.Parent = LocalPlayer.Character
 	print("After hat declaration, hat is: ",hat)
 	Humanoid:AddAccessory(hat)
 end)

Gave this a quick shot, but did not work… thanks for the suggestion though!

Just tried this out and it worked! Thanks!

No problem I am happy to help :grin: