Disguise SWEP

Can anyone get those to work?

[addons\disguise swep\lua\weapons\weapon_disguise\shared.lua:1] attempt to call global ‘LocalPlayer’ (a nil value)
E

i’m getting that error.
also, when i click on the weapon in the weapons section, it doest equip.
here is the shared.lua

local plr = LocalPlayer()
if( SERVER ) then
AddCSLuaFile( “shared.lua” )
SWEP.Weight = 50
SWEP.AutoSwitchTo = false
SWEP.AutoSwitchFrom = false
function DisguiseMDL(player,commands,args)
if type(args[1]) != “string” then return end
if args[1] != “models/player/arctic.mdl” then
Disguise = true
end
util.PrecacheModel( args[1] )
player:SetModel( args[1] )
end
concommand.Add(“disguise_mdl”,DisguiseMDL)

function PlayerDeath(victim,weapon,killer)
	if killer == plr then
		umsg.Start("PlayerGotKilled",killer)
			umsg.Entity(killer)
		umsg.End()
	end
end
hook.Add("PlayerDeath","afolafhaflhu",PlayerDeath)

end

if( CLIENT ) then
SWEP.PrintName = “Disguise Kit”
SWEP.Slot = 0
SWEP.SlotPos = 3
SWEP.DrawAmmo = false
SWEP.DrawCrosshair = false
–Thief Gangster Cop Citizen(lol?)
local GMdl = {“models/player/barney.mdl”,“models/player/group03/male_01.mdl”,“models/player/police.mdl”,“models/player/group01/male_01.mdl”}
function DisguiseMenu()
–Menu code, hacked from DarkRP.
local frame = vgui.Create( “DFrame” )
frame:SetTitle( “Choose disguise” )
frame:SetVisible(true)
frame:MakePopup()

	local levels = 1
	local IconsPerLevel = math.floor(ScrW()/64)
					
	while #GMdl * (64/levels) > ScrW() do
		levels = levels + 1
	end
	frame:SetSize(math.Min(#GMdl * 64, IconsPerLevel*64), math.Min(90+(64*(levels-1)), ScrH()))
	frame:Center()
					
	local CurLevel = 1
	for k,v in pairs(GMdl) do
		local icon = vgui.Create("SpawnIcon", frame)
		if (k-IconsPerLevel*(CurLevel-1)) > IconsPerLevel then
			CurLevel = CurLevel + 1
		end
		icon:SetPos((k-1-(CurLevel-1)*IconsPerLevel) * 64, 25+(64*(CurLevel-1)))
		icon:SetModel(v)
		icon:SetIconSize(64)
		icon:SetToolTip()
		icon.DoClick = function()
			
			RunConsoleCommand("disguise_mdl",v)
			frame:Close()
		end
	end
end
usermessage.Hook("OpenDisguiseGUI",DisguiseMenu)
function PlayerDead(msg)
	person = msg:ReadEntity()
	if person == LocalPlayer() then
		RunConsoleCommand("disguise_mdl","models/player/arctic.mdl")
	end
end
usermessage.Hook("PlayerGotKilled",PlayerDead)

end

SWEP.Base = “weapon_base”

SWEP.Author = “Meoowe(SWEP), Rifleman223(GUI)”
SWEP.Instructions = “Primary Fire : Open Disguise Menu
Secondary Fire : Toggle Cloak
Reload : Undisguise”
SWEP.Contact = “”
SWEP.Purpose = “”
SWEP.Spawnable = true
SWEP.AdminSpawnable = true

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = “none”
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = “none”

SWEP.ViewModel = “models/weapons/v_RPG.mdl”
SWEP.WorldModel = “models/weapons/w_package.mdl”

function SWEP:Initialize()
if( SERVER ) then
self:SetWeaponHoldType( “slam” )
end
end
Disguise = false
local plr
function SWEP:PrimaryAttack()
plr = self.Owner
if( SERVER )then
umsg.Start(“OpenDisguiseGUI”,plr)
umsg.End()
end
end
–util.PrecacheModel( “models/player/”…Mdl…".mdl" )
–self.Owner:SetModel( “models/player/”…Mdl…".mdl" )

conceal = false
function SWEP:SecondaryAttack()
if ( !conceal ) then
self.Owner:SetColor( 0, 0, 0, 0, 50 )
self.Weapon:SetColor( 0, 0, 0, 0, 50 )
self.Owner:PrintMessage( HUD_PRINTCENTER, “Invisible” )
conceal = true
else
self.Owner:SetColor( 255, 255, 255, 255 )
self.Weapon:SetColor( 255, 255, 255 )
self.Owner:PrintMessage( HUD_PRINTCENTER, “Visible” )
conceal = false
end

end

function SWEP:Reload()
if CLIENT then
Disguise = false
RunConsoleCommand(“disguise_mdl”,“models/player/arctic.mdl”)
end
end

function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )
draw.SimpleText( “H”, “CSSelectIcons”, x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end

[lua]

–Menu code, hacked from DarkRP.
local frame = vgui.Create( “DFrame” )
frame:SetTitle( “Choose disguise” )
frame:SetVisible(true)
frame:MakePopup()
[/lua]

I died a little bit. That isn’t even basic derma and you needed to take from DRP?

LocalPlayer() isn’t defined on the server.

i didnt make it? huh?

Because if some code looks exactly in almost every script/gamemode, it means that it’s stolen. :downs:

can someone still fix it though?

Read line one of that code.

and Top Puppy, LocalPlayer() doesn’t work on the server. Just put it with the rest of the client side stuff.

In server put this: plr = self.Owner
client: plr = LocalPlayer()

Building on Science’s suggestion:

[lua]
local plr

if ( SERVER ) then

 plr = self.Owner

else

 plr = LocalPlayer()

end
[/lua]

Its too bad I sucked at coding when I made that.

You sucked so bad you couldn’t figure out how to make a DFrame with a title, but a spawnicon was doable?