Button Data VGUI

Hello all,

I am trying to change the text and have it do something else based on a table containing something or not. It’s not working, and I would really like it to work.


if CLIENT then
	-- LocalPlayer.somefunction = function(text) end
	
	
	
	function PBalls(Panel)
		Panel:ClearControls()
		
		 button = vgui.Create("DButton")
		
		button:SetParent(Panel)
		button:SetPos(25, 50)
		button:SetSize( 100, 30)
		--net.Receive("gotcha!", function () button:SetText("Pokeball " .. net.ReadString()) end)
		if pokemoncaught[1] ~= nil then
			button.DoClick = function()
			net.Start("give_monster")
			print("what!?")
			net.SendToServer()
			buttons = 1
			button:SetText(pokemoncaught[1]:GetClass())
			end
		else
			button.DoClick = function()
			button:SetText("empty")
			net.Start("pokeball_give")
			net.SendToServer()
			buttons = 1
		end
		end
	end

	function Addoption()
		spawnmenu.AddToolMenuOption("Backpack",
			"Pokeballs",   
			"PBalls",  
			"Pokeballs",    "",    "",   
			PBalls,
			{})
	end
	hook.Add("PopulateToolMenu", "Addoption", Addoption)

	local function AddCats()	
		spawnmenu.AddToolCategory("Backpack", "Pokeballs", "Pokeballs")
	end
	hook.Add("AddToolMenuTabs", "AddCats", AddCats)
else
	AddCSLuaFile("server.lua")
	util.AddNetworkString("pokeball_give")
	util.AddNetworkString("give_monster")
	util.AddNetworkString("gotcha!")
	
	
	net.Receive("pokeball_give", function (a, b, c) b:GetClass():Give("pokeball_capture") end)
	net.Receive("give_monster",  function(len, ply) ply:Give("pokeball_base") ply:GetWeapon("pokeball_base"):SetSpawn(pokemoncaught[buttons]) end)
end
--buttons = 0

For some reason, when I click the button to change the text, it doesn’t change and it still gives me an empty pokeball SWEP. Plus, it DOES have a value in pokemoncaught[1] when I click it (cause I try it)