-
What do you want to achieve?
For the hat to successfully be out onto the player’s head.
-
What is the issue?
Whenever the game runs, I get this error:
AddAccessory should be passed a valid Accessory object.
-
What solutions have you tried so far?
I tried using a part of a code on the DevHub, but it didn;t work.
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local ServerStorage = game:GetService("ServerStorage")
local Hat = ServerStorage:WaitForChild("tophat"):Clone()
Humanoid:AddAccessory(Humanoid)
4 Likes
When you called the :AddAccessory() method, you put Humanoid as the first parameter when it’s supposed to be the actual accessory.
Try this:
Humanoid:AddAccessory(Hat)
My bad, thank you for pointing that out.
But now, The hat doesn’t appear?
There aren’t any errors.
1 Like
Then don’t use :AddAccessory()
maybe this will work:
local Character = script.Parent
local Humanoid = Character:WaitForChild("Humanoid")
local ServerStorage = game:GetService("ServerStorage")
local Hat = ServerStorage:WaitForChild("tophat"):Clone()
Hat.Parent = Character
Still doesn’t maybe I need to add a offset or something? No clue.
Check the explorer, is the hat actually parented to the character?
1 Like
And does your hat have a ‘Handle’ part with an attachment?
1 Like
The hat is parented, but it doesn’t add it to the player. It’s unanchored, by the way.
Remove the WeldConstraint (you don’t need it),
Put the Mesh in the Part with the HatAttachment,
Remove the ‘fedora’ part.
That should work I think
1 Like
Still no, I think it might need a offset or something.
Can you upload it as a model to Roblox and send the id so I can have a look at it please?
I’ll try and see what the problem is
HatGiver.rbxm (4.1 KB)
Script goes in StarterCharacterScripts, tophat goes into ServerStorage.
1 Like
The file format isn’t working for some reason, try saving the entire place to file and sending it maybe
Try this:
HatGiver2.rbxm (4.7 KB)
I got it nevermind, I just needed to drag it into roblox studio.
Sorry
I found the hat, it looks like the attachment didn’t weld it to the head.
1 Like
So what do I need to do now? (charr)
I found the problem, you didn’t name the part “Handle” this is crucial for an accessory to work.
1 Like
Thank you, it works now. Thank you for the help!
1 Like