Hats - Help Please

So I am new to Glua and learnt most of the basics.
I was hoping to make a hat, anyone mind helping? I’ve done some research but not found too much or at least helpful things for a noobie like me.
Anyone mind making a simple hat that has comments explaining what each part does, I don’t understand how to make the entity or set the bones to stick the entity onto the head.

If you could help I will be incredibly grateful and hopefully further develop my lua knowledge.

So you did research and you didn’t come across other threads on facepunch that i’m sure have been made more than once asking the same question?

You could have looked inside pointshop to see how you could accomplish this too.
hook.Add(‘PostPlayerDraw’, ‘PS_PostPlayerDraw’, function(ply)
if not ply:Alive() then return end
if ply == LocalPlayer() and GetViewEntity():GetClass() == ‘player’ and (GetConVar(‘thirdperson’) and GetConVar(‘thirdperson’):GetInt() == 0) then return end
if not PS.ClientsideModels[ply] then return end

for item_id, model in pairs(PS.ClientsideModels[ply]) do
	if not PS.Items[item_id] then PS.ClientsideModel[ply][item_id] = nil continue end

	local ITEM = PS.Items[item_id]

	if not ITEM.Attachment and not ITEM.Bone then PS.ClientsideModel[ply][item_id] = nil continue end

	local pos = Vector()
	local ang = Angle()

	if ITEM.Attachment then
		local attach_id = ply:LookupAttachment(ITEM.Attachment)
		if not attach_id then return end

		local attach = ply:GetAttachment(attach_id)

		if not attach then return end

		pos = attach.Pos
		ang = attach.Ang
		local bone_id = ply:LookupBone(ITEM.Bone)
		if not bone_id then return end

		pos, ang = ply:GetBonePosition(bone_id)

	model, pos, ang = ITEM:ModifyClientsideModel(ply, model, pos, ang)




Sorry, I’m new to lua, I don’t really understand any of this.
I have also looked at most of the posts on hats, but the people that ask know what they’re doing. I don’t really understand what it means and I’m asking for something that will help me understand each line of code.
I have also looked at the Point Shop hats and tried to implement it into my own code but I’ve had no luck.