Why is this script not working?

Why will this script not work?
I’m trying to make a script were a player automatically gets a hat on their avatar.
However every time I join the script works but the hat doesn’t attach to the player.
I have inserted a attachment into the hat.
Here is the script:

local Rep = game:GetService("ReplicatedStorage")  
local Players = game:GetService("Players") 


local Hat = Rep:WaitForChild("Hat") 

Players.PlayerAdded:Connect(function(Player)
	Player.CharacterAdded:Connect(function(Character)
		Hat:Clone().Parent = Character

	end)
end)

The code looks right. Is the attatchment actually attatched to the head? you could check if the hat is parented to the character if so there is a problem with the attachment and not the code

I put a FaceCenterAttachment into it.

The hat is a mask.
Pretty sure FaceCenterAttachment is right

The ONLY thing inside the mask is FaceCenterAttachment

1.- is the mask parented to the character? that would be the first thing to check
2.- FaceCenter is inside the head so it would be easier to use FaceFront but its up to you
3.- is the mask an accesory? i haven’t tested this but when i attatch something to the player i always use an accesory object although im not 100% sure it has to be an accesory to work

1.I’m not sure what you mean parented to a character
2.I’ll try FaceFront
3.The mask is an accessory

the character is the visible player, it is the model that you can find in the workspace with the player name

i just copied your code and created a hat object with a part called “Handle” with an attatchment inside it called “FaceFrontAttatchment” and this is the result
image
this is how the hat looks like in the explorer
image

Try using weld constraints for your character and hat.

Okay I got it to work now the only problem I’m having is the mask is rotated wrong and the straps are at the front of the face

EDIT: I rotated the FaceCenterAttachment and it worked

Make this your solution then, so people don’t think this topic is still going.