Set Position of Hat

[lua]
local hats = { }

local function CreateHat( ply, model )
SafeRemoveEntity( ply.Hat )

local hat

hat = ClientsideModel( model, RENDERGROUP_OPAQUE )
hat:SetNoDraw( true )

ply.Hat = hat
hat.Owner = ply
table.insert( hats, hat )

end

local function CleanHats( )
local k, v

for k, v in pairs( hats ) do
	if not IsValid( v ) then
		hats[ k ] = nil
	elseif not IsValid( v.Owner ) then
		SafeRemoveEntity( v )
		hats[ k ] = nil
	end
end

end

local function DrawHats( )
local k, v, pos, ang

CleanHats( )

for k, v in ipairs( player.GetAll( ) ) do
	if not v:Alive( ) and IsValid( v.Hat ) then
		SafeRemoveEntity( v.Hat )
		v = v:GetRagdollEntity( )
	end

	if not IsValid( v.Hat ) then
		CreateHat( v, "models/player/items/humans/top_hat.mdl" )
	end

	pos, ang = v:GetBonePosition( 6 )

	v.Hat:SetPos( pos )
	v.Hat:SetAngles( ang )
	v.Hat:DrawModel( )
end

end

hook.Add( “PostDrawOpaqueRenderables”, “Draw Hats.PostDrawOpaqueRenderables”, DrawHats )
[/lua]

(I’m New to Lua, Explaining as much as you can will help a lot)
Anyone mind helping setting the position of the hat? Like an example on repositioning the entity and maybe explaining what each bit does.
Edit-
Also how to set the Entities/model size.

Anyone help? Like an example of how RotateAroundAxis(Blablalba) works.


// this is a table/array
local hats = { }

// function that is passed players(ply) and models
local function CreateHat( ply, model )
	SafeRemoveEntity( ply.Hat ) // i assume this removes the hat before a new one can be drawn (dunno)

	local hat // hat variable. starts blank

	hat = ClientsideModel( model, RENDERGROUP_OPAQUE ) // http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7401.html
	hat:SetNoDraw( true ) //http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/indexcf29.html

	ply.Hat = hat // set the hat entity to your hat variable
	hat.Owner = ply // set the hats owner to player
	table.insert( hats, hat ) // insert the hat into the hats table
end

local function CleanHats( )
	local k, v // key(k) and value(v)

	for k, v in pairs( hats ) do // for each key(12345) and value(its name)
		if not IsValid( v ) then // if not a valid hat
			hats[ k ] = nil // set it to blank
		elseif not IsValid( v.Owner ) then // otherwise
			SafeRemoveEntity( v ) // remove the hat
			hats[ k ] = nil // then set it to nil
		end
	end
end

local function DrawHats( )
	local k, v, pos, ang // key, value, position, angle

	CleanHats( ) // call the clean hats function

	for k, v in ipairs( player.GetAll( ) ) do // for each player
		if not v:Alive( ) and IsValid( v.Hat ) then // if the player is alive and there is a valid hat selected
			SafeRemoveEntity( v.Hat ) // remove the hat
			v = v:GetRagdollEntity( ) // http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index1230.html
		end

		if not IsValid( v.Hat ) then // if there's a legit hat
			CreateHat( v, "models/player/items/humans/top_hat.mdl" ) // create the hat
		end

		pos, ang = v:GetBonePosition( 6 ) // get the position and angle. http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index22b6.html

		v.Hat:SetPos( pos ) // set the hats position aka on players head
		v.Hat:SetAngles( ang ) // set the angle of the hat
		v.Hat:DrawModel( ) // create the hat
	end
end

hook.Add( "PostDrawOpaqueRenderables", "Draw Hats.PostDrawOpaqueRenderables", DrawHats ) // http://maurits.tv/data/garrysmod/wiki/wiki.garrysmod.com/index7e79.html

I have never seen this code before but with about 5 minutes of research I understand most of it. Raging doesn’t really make anyone want to help you either.

Next time don’t be like ‘oh here’s a bunch of code that I don’t know how it works, can someone explain it to me?’ Do the research and post a specific question.