Issues with securing remotes

I’ve searched on DevForums for a while and came up with nothing good until I figured that I could just use a table of users that can fire remotes.

Small problem,
I’ve tested it on myself by making a check if the Player.Name is inside the ModuleScript Table filled with users.
If attempted to be fired, the player should be kicked and the remote should NOT get fired.

Here’s my script for checking… (LocalScript)

deleted code

No errors in output show up when the client-side check is being executed.

I’ve already tried Server-side checks with worked partly but of course the server cannot access LocalPlayer… so it couldn’t kick, although it still fired the remote.

local Whitelist = require(game.ReplicatedStorage:WaitForChild("Technica"):WaitForChild("Administrators"))
local Player = game.Players.LocalPlayer

API.OnClientEvent:Connect(function()
	for Index, PlayerInList in pairs(Whitelist) do
		if Player.Name ~= PlayerInList then
			Player:Kick("Attempted to fire a remote.")
			warn(Player.Name.." attempted to fire a remote while unwhitelisted.")
		end
	end
end)

You made a mistake in pairs, you named the player you received as “WhiteList” and the script could not identify the player you are checking on the name or table WhiteList, maybe I explained it wrong, but the new script does not seem to have an error (maybe)

Same thing happens.
No errors and the player was not kicked.

Remote also still fires

30charxs

Your script is in a local script. Try putting it in a server script (and removing local Player = game.Players.LocalPlayer)

local Whitelist = require(game.ReplicatedStorage:WaitForChild("Technica"):WaitForChild("Administrators"))
local Player = game.Players.LocalPlayer

API.OnClientEvent:Connect(function()
	local PlayerFindedInList = false
	for Index, PlayerInList in pairs(Whitelist) do
		if Player.Name == PlayerInList then
			PlayerFindedInList = true
		end
	end
	if PlayerFindedInList then
		-- If need
	else
		Player:Kick("Attempted to fire a remote.")
		warn(Player.Name.." attempted to fire a remote while unwhitelisted.")
	end
end)

Hell why did I make such a big thing out of this, thank you, all I needed was to remove LocalPlayer like you said…

Thanks again.

Well um now we have a different problem though…

It kicks users even if they are in the Whitelist Table

can you please send me the script that has the player list?

This is a Module Script.

--[[
	This ModuleScript is for whitelisting administrators for your game, to use Technica.
	You can add as many as you want, just put a , after each user.
	To remove an admin, just remove their name or entire line.
]]--


local Administrators = {
	"Luhkaaa",
	"Millersons"
}

return Administrators

Try using this script as the one that kicks the users:

local Whitelist = require(game.ReplicatedStorage:WaitForChild("Technica"):WaitForChild("Administrators"))
API.OnClientEvent:Connect(function(Player)
	if not table.find(WhiteList, Player.Name) then
		Player:Kick("Attempted to fire a remote.")
		warn(Player.Name.." attempted to fire a remote while unwhitelisted.")
	end
end)

The reason your script kicked you regardless, is because if you didn’t have the name of both the whitelisted people, it would kick you. I provided a smaller script that kicks only if your name never appears in it

This should be in a LocalScript or script?

Because uh,
image

try:

API.OnServerEvent:Connect(function(Player)
	if not table.find(WhiteList, Player.Name) then
		Player:Kick("Attempted to fire a remote.")
		warn(Player.Name.." attempted to fire a remote while unwhitelisted.")
	end
end)

Now this finally fixed my entire issue, thank you extremely much.

There’s a word for “unwhitelisted”, it’s “blacklisted”.