Material on Player

Is it possible to put a material on a player? Like if I wanted to pull out a knife and right click to make me semi-invisible. I want to know about material not I want to apply a material to the player, and also for it to work in multilayer.

Yes you can set materials to players.

could you give me an example of a player one and not a prop_physics one?

No, it’s exactly the same. Get a player object and call the function on it.

Player object? Sorry I am not to good at remembering all the lua things. please explain in more detail.

[lua]Player:SetMaterial( “models/shiny” );
Player:SetColor( 0, 0, 200, 255 );[/lua]

Will result in:

Hope this helps.

local plobj = player.GetAll()[ 1 ]
// Get the player who’s EntIndex is 1.
// Doing things to this variable will effect that player

plobj:SetMaterial( “dir” )
// Change that player’s material

// Using the format ‘Variable : (colon) Function’ is called a meta or meta function
// and is also a shortcut to ‘metatable . (dot) Function ( Variable )’


By the way I forgot to mention, if you’re making knife (so your own SWEP) then to get the Player object you get the SWEP’s owner self:GetOwner();


local Owner = self:GetOwner();
Owner:SetMaterial( “models/shiny” );

ok, it works Great! but now I need it to toggle on/off, and to turn off when the player dies.

would is be like

If owner dies then



I would also like to so something like this. (taken from Conna’s Tools - Cloaking Tool)
function TOOL.TakeDamage(Entity, Attacker, Inflictor, Damage)
if (Entity.Cloaking and Entity.Cloaking.Cloaked) then
if (Entity.Cloaking.Flicker) then

			timer.Simple(0.05, Cloaking.Activate, Entity)


Could I do this but only for a player/owner?