Lua help

Hi I am trying to make an AFK kicker but i keep getting errors


local function AFKKicker()	
	ply.butRelease = 0
	ply = player.GetAll()
	ply.butRelease = CurTime()
	if CurTime() - ply.butRelease < 5 then
	ply:Kick( "You were afk for to long" )
	end
end
hook.Add("PlayerButtonUp", "ButtonLetGo", AFKKicker)
local function AFKCheck()
	ply.butRelease = 0
	ply = player.GetAll()
	if (CurTime() >= ply.butRelease) then
		end
	end	
hook.Add("Think", "thinkhook", AFKCheck)

also i do not want some huge code you made or a download one i want someone to help me fix mine my error at the moment is
[ERROR] addons/brettscripts/lua/autorun/server/afkkicker.lua:6: attempt to call method ‘Kick’ (a nil value)

  1. v - addons/brettscripts/lua/autorun/server/afkkicker.lua:6
  2. unknown - lua/includes/modules/hook.lua:84

Not to be rude, but your code is all over the place.

  1. player.GetAll() returns a table of all players, so defining ply as that wouldn’t work.
  2. The PlayerButtonUp hook passes ply as an argument, so make sure to use it.
  3. Your code simply won’t work.


hook.Add("PlayerButtonUp", "PlayerPressedKey", function(ply)
	ply.ButtonPressed = CurTime(); //set the player's last button pressed time to now
end)

hook.Add("Think", "KickAFKPlayers", function()
	for k,v in pairs(player.GetAll()) do //loop through all players to see if any are afk and need kicked.
		v.ButtonPressed = v.ButtonPressed or 0 //make sure v.ButtonPressed is defined, as the player may not have actually pressed a button yet. Therefore it would be nil.
		
		if (CurTime() - v.ButtonPressed < 300) then //60 seconds * 5 = 300. Subtract CurTime() - the last time the player pressed a button to determine if it has been five minutes.
			v:Kick("You were afk too long!"); //Player was afk too long, kick them.
		end
	end
end)


I fixed this but is there away to make a derma panel pop up that if the player clicks it will stop the afk timer