Hat doesnt go to player

I made this tool where it does an animation then gives a hat, but the problem is that the hat spawns where it was inserted somewhere on the workspace but doesn’t glue to the player’s head. How can I fix this? Here is the script:

local tool = script.Parent
local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local torso = Character:WaitForChild("Torso")
local CharMesh = game:GetService("ReplicatedStorage").CharacterMesh
local Hum = Character:WaitForChild("Humanoid")
local CatEars = game:GetService("ReplicatedStorage").Hats.FluffyEars

tool.Activated:Connect(function()
	print("anim1 loaded")
	Hum.WalkSpeed = 0
	local Character2 = tool.Parent
	
	local Anim = Instance.new("Animation")
	Anim.AnimationId = "http://www.roblox.com/asset/?id=6852687034"

	local LoadAnim = Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Anim)
	LoadAnim:Play()
	
	wait(4)
	print("anim2 loaded")
	local Anim2 = Instance.new("Animation")
	Anim2.AnimationId = "http://www.roblox.com/asset/?id=6857206465"
	
	local LoadAnim2 = Character:WaitForChild("Humanoid"):WaitForChild("Animator"):LoadAnimation(Anim2)
	LoadAnim2:Play()

	wait(1.6)
	local Ears = CatEars:Clone()
	Ears.Parent = Character
	print("Ears added")
	local Mesh = CharMesh:Clone()
	Mesh.Parent = Character
	print("Added mesh")
	wait(1)
	Hum.WalkSpeed = 16
	tool:Destroy()
end)

at the bottom part of the script you can see where it prints Ears added that’s where it clones the hat.

Use Humanoid:AddAccessory(accessory), it’s very useful and I use it in a lot of my games.

Also when using this, I’d recommend doing CatEars:Clone() inside of the parameters of AddAccessory (you’d probably already do this but I didn’t at first)

1 Like