Assistance with Errors!

I have been looking through my code for a while now and have no idea why this code is getting errors.

The Code:

init.lua:


AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( "shared.lua" )

function ENT:Initialize()

	self:SetModel( "models/props/cs_assault/MoneyPallet.mdl" )
	self:PhysicsInit(SOLID_VPHYSICS)
	self:SetMoveType(MOVETYPE_VPHYSICS)
	self:SetSolid(SOLID_VPHYSICS)
	self:SetUseType( SIMPLE_USE )

	local phys = self:GetPhysicsObject()

	if phys:IsValid() then

		phys:Wake()

	end	

end

util.AddNetworkString( "OpenBankMenu" )
function ENT:AcceptInput( name, activator, caller )

	if name == "Use" and caller:IsPlayer() then
		net.Start( "OpenBankMenu" )
		net.Send( caller )
	end

end

util.AddNetworkString("BankRobberyStarted")
net.Receive("BankRobberyStarted", function()

	net.Broadcast("BankRobberyStarted")

end)

cl_init.lua:


include( "shared.lua" )

surface.CreateFont( "PoliceAmmoMenuFont", {
    font = "Arial", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
    size = 35,
    weight = 500,
    blursize = 0,
    scanlines = 0,
    antialias = true,
    underline = false,
    italic = false,
    strikeout = false,
    symbol = false,
    rotary = false,
    shadow = false,
    additive = false,
    outline = false,
} )

function ENT:Draw()

	self:DrawModel()

end

local BankBalance = 25000

timer.Create( "BankBalanceChanging", 180, 0, function() 

	BankBalance = BankBalance + math.random( 2500, 15500 )

end)

local ply = LocalPlayer()

net.Receive( "OpenBankMenu", function()

    local Background = vgui.Create( "DFrame" )
    Background:SetSize( 500, 750 )
    Background:Center()
    Background:SetTitle("")
    Background:SetVisible( true )
    Background:ShowCloseButton( true )
    Background:SetDraggable( true )
    Background.Paint = function(s, w, h)

        draw.RoundedBox( 10, 0, 0, w, h, Color(20,255,20,255))

    end
    Background:MakePopup()

    local CloseBut = vgui.Create( "DButton", Background )
    CloseBut:SetSize( 150, 30 )
    CloseBut:SetPos( 250, 250+100)
    CloseBut:SetText("Close")
    CloseBut:SetColor( Color(0,191,255,255) )
    CloseBut.Paint = function(s, w ,h)
    	draw.RoundedBox( 10, 0, 0, w, h,Color(0,0,0,255))
	end
    function CloseBut:DoClick()

    	Background:Remove()

    end

    local RobberyBut = vgui.Create( "DButton", Background )
    RobberyBut:SetSize( 150, 30 )
    RobberyBut:SetPos( 250, 250-100)
    RobberyBut:SetText("Start A Robbery")
    RobberyBut:SetColor( Color(255,0,0,255) )
    RobberyBut.Paint = function(s, w ,h)
    	draw.RoundedBox( 10, 0, 0, w, h,Color(0,0,0,255))
	end

    function RobberyBut:DoClick()

    	if not ply:Team() == TEAM_CITIZEN then 
    		DarkRP.notify( 1, 10, "You Can't Rob the bank whilst you are employed by the government!")
    		Background:Remove()
               return 
        end

    	if ply:Team() == TEAM_CITIZEN then
    		net.Start("BankRobberyStarted")	
    		net.SendToServer()
    	end

    end

end)

net.Receive( "BankRobberyStarted", function()

	if ply:Team() == TEAM_POLICE then
		chat.AddText( Color(0,191,255), "211S(Robbery, Silent Alarm) at the 10-20 Bank! All units please respond!", Color(0,0,255), "SWAT", Color(0,191,255), "have been dispatched!")
	end 

end)

shared.lua:


ENT.Type = "anim"
ENT.Base = "base_gmodentity"

ENT.PrintName = "Metro Bank"

ENT.Spawnable = true

The errors I am getting are:




[ERROR] addons/darkrpmodification-master/lua/entities/bank_robbery_ent/cl_init.lua:62: attempt to call field 'notify' (a nil value)
  1. DoClick - addons/darkrpmodification-master/lua/entities/bank_robbery_ent/cl_init.lua:62
   2. unknown - lua/vgui/dlabel.lua:218


&



[ERROR] addons/darkrpmodification-master/lua/entities/bank_robbery_ent/cl_init.lua:92: attempt to call method 'Team' (a nil value)
  1. DoClick - addons/darkrpmodification-master/lua/entities/bank_robbery_ent/cl_init.lua:92
   2. unknown - lua/vgui/dlabel.lua:218


Thank you for your help!

  • Shadow

[editline]2nd April 2016[/editline]

bump

Your errors and codes don’t match.
The 1st error shows that ‘notify’ is in line 62 when it’s in 78 (In the supplied cl_init)
The 2nd error shows that ‘Team’ is in line 92 when it’s in 94 (In the supplied cl_init)

We’re gonna need the correct files for this.

Assuming the codes are the same but line numbers are different then I can say this:

1st error: DarkRP.notify is a server-side function, so it doesn’t work on the client (And it doesn’t seem as if you are using it correcty at all)

2nd error: ply seems to be undefined in your function, and so Team can’t be called because it’s a Player function.

At the top of the code it says:


local ply = LocalPlayer()

if this is what you mean!