RemoteEvents Help

Right, so people have advised me that I should add verifications to my admin panel’s remote events so hackers cannot use it against us. Anyways it has been an amazing bit of code the person recommended for me to use but I have having issues using it with the last 2 functions. No errors so I have no Idea as to why they are not working.

Primary Security Script for RemoteEvents
script.Parent.RemoteEvent.OnServerEvent:Connect(function(plr,plrtounban,status)
	
	script.Parent.OnServerEvent:Connect(function(plr)
		if not table.find(admins, plr.UserId) then
			-- user using the remote is a bad actor, punish them and drop the request
			return plr:Kick("Tampering with Remotes");
		end
	end)
	
end)

Anyways the first function it is not working for is the Server Shutdown one.

Code
local config = require(script.Parent.Parent.Parent.Config)
local admins = config.adminIDs
local shutdown = false

script.Parent.OnServerEvent:Connect(function(player)
	if not table.find(admins, player.UserId) then
		-- user using the remote is a bad actor, punish them and drop the request
		shutdown = false
		return player:Kick("Tampering with Remotes");
	end

	for k, value in next, game.Players:GetPlayers() do

		value:Kick("This server has been shutdown by an Admin.")
	end

	shutdown = true
end)

function onJoin(player)

	if shutdown then

		player:Kick("This server has been shutdown by an Admin.")
	end
end

game.Players.PlayerAdded:Connect(onJoin)

I do have a pretty good idea as to why it is not kicking the person who is not an admin who fired the server. I believe its because it actually does but its to late because it follows through with the function to kick everyone in the server. So basically I am asking how to cancel kicking everyone from the server. I know it has to go in the then part of the script but thats it for that.

After that one I am having the issue with the unban handler.

Code
local config = require(script.Parent.Config)
local admins = config.adminIDs
local datastoreservice = game:GetService("DataStoreService") -- These two lines are the datastores
local bandata = datastoreservice:GetDataStore(config.DataStoreKey)


script.Parent.Unban.OnServerEvent:Connect(function(plr,plrtounban,status)

	local uid = game.Players:GetUserIdFromNameAsync(plrtounban) -- They won't be in the game so we get the id 
	bandata:SetAsync(uid,{".",".","."}) -- Sets it to something without the id in the first column in the datastore
	status.Text = "Unbanned: "..plrtounban.."" -- The status message in the gui
end)

Unlike the shutdown one I have no idea why it is not working when It worked fine for the ban function. Please help me, it would be very appreciated.