RP Money Button, Nill value

Hello, so I’m trying to make a button that you click and it gives you money.
When I try to press the button I get a nill value error.

Here’s the code:



if CLIENT then

local function DankMemes()

local frame = vgui.Create("DFrame")
frame:SetSize( 1200, 600 )
frame:Center()
frame:SetVisible( true )
frame:MakePopup()
frame:SetTitle( "        Node Core" )
frame:ShowCloseButton( false )
frame:SetSizable( false )
frame.Paint = function( self, w, h )
	draw.RoundedBox( 30, 0, 0, w, h, Color( 21, 76, 230, 150 ))
end

local panel = vgui.Create("DPanel", frame)
panel:Dock(FILL)
panel:DockMargin(-5, -5, -5, -5)

local text = vgui.Create("DLabel", panel)
text:SetSize(300, 50)
text:SetPos(10, 0)
text:SetTextColor(Color(33, 33, 33))
text:SetText("          Enabling Node Core can dramatically increase fps.")

local ybtn = vgui.Create("DButton", panel)
ybtn:SetText("Enable")
ybtn:SetPos(100, 45)
ybtn:SetSize(100, 25)
ybtn:SetTextColor(Color(0, 0, 255))

local nbtn = vgui.Create("DButton", panel)
nbtn:SetText("Disable")
nbtn:SetPos(100, 75)
nbtn:SetSize(100, 25)
nbtn:SetTextColor(Color(255, 0, 0))

local xbtn = vgui.Create("DButton", panel)
xbtn:SetText("X")
xbtn:SetPos(1170, 10)
xbtn:SetSize(25, 25)
xbtn:SetTextColor(Color(255, 0, 0))

local cbtn = vgui.Create("DButton", panel)
cbtn:SetText("+ 5$")
cbtn:SetPos(1000, 100)
cbtn:SetSize(100, 100)
cbtn:SetTextColor(Color(0, 0, 0))

function ybtn:Paint(w, h)
draw.RoundedBox(3, 0, 0, w, h, Color(255, 255, 255, 255))
end

function nbtn:Paint(w, h)
draw.RoundedBox(3, 0, 0, w, h, Color(255, 255, 255, 255))
end

function xbtn:Paint(w, h)
draw.RoundedBox(3, 0, 0, w, h, Color(255, 0, 0, 155))
end

function cbtn:Paint(w, h)
draw.RoundedBox(3, 0, 0, w, h, Color(255, 255, 255, 155))
end

ybtn.DoClick = function()
LocalPlayer():ConCommand("gmod_mcore_test 1")
LocalPlayer():ConCommand("mat_queue_mode -1")
LocalPlayer():ConCommand("cl_threaded_bone_setup 1")
LocalPlayer():ConCommand("cl_threaded_client_leaf_system 1")
LocalPlayer():ConCommand("r_threaded_particles 1")
LocalPlayer():ConCommand("r_threaded_renderables 1")
LocalPlayer():ConCommand("r_queued_ropes 1")
LocalPlayer():ConCommand("studio_queue_mode 1")
end

nbtn.DoClick = function()
LocalPlayer():ConCommand("gmod_mcore_test 0")
LocalPlayer():ConCommand("mat_queue_mode 0")
LocalPlayer():ConCommand("cl_threaded_bone_setup 0")
LocalPlayer():ConCommand("cl_threaded_client_leaf_system 0")
LocalPlayer():ConCommand("r_threaded_particles 0")
LocalPlayer():ConCommand("r_threaded_renderables 0")
LocalPlayer():ConCommand("r_queued_ropes 0")
LocalPlayer():ConCommand("studio_queue_mode 0")
end

xbtn.DoClick = function()
frame:Remove()
end

cbtn.DoClick = function()
DankMoney()
end

end

hook.Add( "OnPlayerChat", "UNIQUEIDENT", function( ply, str, bteam, bdead )

	if ply ~= LocalPlayer() then return end

	str = string.lower( str )
	
	if( str == "!gui" ) then
		DankMemes()
	end
	end)

end

local function DankMoney( ply )

	if ply ~= LocalPlayer() then return end

	ply:AddMoney(5)
	
end


Here’s the error that I’m getting when I try to click the button:



[ERROR] addons/nodecore/lua/autorun/dankmemes.lua:113: attempt to index local 'ply' (a nil value)
  1. DankMoney - addons/nodecore/lua/autorun/dankmemes.lua:113
   2. DoClick - addons/nodecore/lua/autorun/dankmemes.lua:94
    3. unknown - lua/vgui/dlabel.lua:232


If you read where you call the function, DankMoney, you don’t pass any arguments into the function. Just get rid of the argument and just do


LocalPlayer():addMoney(5)

and DarkRP doesn’t use Player:AddMoney(), it’s Player:addMoney()

not sure why you’re giving money in that tab lmao INCOMING workshop exploitable addon? kappa.
You’re clicking a button clientside, you must send it to Serverside to call addMoney, ( use net libraries ) to ‘request’ the money.



if SERVER then
	local money_u_want_to_give = 5
	util.AddNetworkString( "awkward_givemoney" )
	net.Receive( "awkward_givemoney", function( len, ply )
		ply:addMoney( money_u_want_to_give )
	end )
end

if CLIENT then
	btn.DoClick = function()
		net.Start( "awkward_givemoney" )
		net.SendToServer()
	end
end


When I use that I get



[ERROR] addons/nodecore/lua/autorun/dankmemes.lua:94: attempt to call global 'DankMoney' (a nil value)
  1. DoClick - addons/nodecore/lua/autorun/dankmemes.lua:94
   2. unknown - lua/vgui/dlabel.lua:232


show us your code

check my reply.

Yeah, thanks B1ts yours works, I just hadn’t reloaded my page.

No problem!
:dance: