Changing color of the viewmodel

I know how to change the color of a weapons world model


if SERVER then
   function SWEP:Initialize()

      self:SetRenderMode( RENDERMODE_GLOW )
      self:SetColor(Color(255,0,0,255))

      return self.BaseClass.Initialize(self)
   end
end

How yould I change the color of the 1st person viewmodel?

local vm=self.Owner:GetViewModel() Do this CLIENTSIDE only, not server.

So would that look like



if CLIENT then
  

      function SWEP:Initialize()
            local vm=self.Owner:GetViewModel()
            vm:SetRenderMode( RENDERMODE_GLOW )
            vm:SetColor(Color(255,0,0,255))

            return self.BaseClass.Initialize(self)

end

yes, except without the syntax error.

Ah, yeah

[editline]21st January 2014[/editline]

that caused this error to run

[ERROR] gamemodes/terrortown/entities/weapons/weapon_ttt_psychostick/shared.lua:547: attempt to call method ‘GetViewModel’ (a nil value)

  1. unknown - gamemodes/terrortown/entities/weapons/weapon_ttt_psychostick/shared.lua:547