[HELP] Player Item Script. How do I have it where the player can use a command to swith clothing.

Like the title explains

here is my clothing script I got off the old gmod wiki.
local model = ClientsideModel( “models/horsie.mdl” )
model:SetNoDraw( true )

hook.Add( “PostPlayerDraw” , “manual_model_draw_example” , function( ply )
ply.horsie = true
if not IsValid( ply ) or not ply:Alive() or ply.horsie == false then return end

local attach_id = ply:LookupAttachment( 'eyes' )
if not attach_id then return end

local attach = ply:GetAttachment( attach_id )

if not attach then return end

local pos = attach.Pos
local ang = attach.Ang

model:SetModelScale( 1, 0 )
pos = pos + ( ang:Forward() * -4.5 ) +  ( ang:Up() * 2 )
ang:RotateAroundAxis( ang:Right(), 20 )

model:SetPos( pos )
model:SetAngles( ang )

model:SetRenderOrigin( pos )
model:SetRenderAngles( ang )

end )

I have a variable called ply.horsie how can I toggle from outside the function and I have it so other people can or can’t see the model
because I have gotten it to disable before but my friend could still see the mask.

[editline]16th November 2016[/editline]

forgot to say its in my shared file sh_items.lua

Interesting. So if you wanna create a function to switch hat add or remove. Thats what u need. But this as far as I think only works on one player thats why need functions to attach into player object as I did.also I hope u are using it on Client. Not matter if shared. Just be under If client then end statment.

In short:
You must create multiple cliensidemodels for each player. To see others hat or anything. Also check if the player has hat created. But mirror like in gm_construct. Dunno how to solve.0