I'm losing my mind over this script [SOLVED!]

I have been trying over and over for days to try and get this code to work but its just not work >:( I have tried everything from kicking the player if their name is the same as the subjects or even using gulp chatgpt gags.

and yet all it does is either kick just me even if my name is not the subjects name. Or it just prints out the “User not found” string, I can’t get my stupid code to work, All I want is a player to get kicked if their name is the same as “Subject” here’s my code.
Screenshot (2013)
Screenshot (2015)
Screenshot (2017)
Please help me, I’m losing my freaking mind.

Edit: Thank you all for the feedback its been helping a lot! :+1:
Edit but 2: Big thanks to “NOCOMPLYMOBY”, turns out all I had to do was add :lower() and it works like a charm! And thanks to everyone that gave me their thoughts on my code, I’m working on trying to improve it.

for Index, Player in pairs(Players:GetPlayers()) do
     if Player.Name == Subject.Name then
           -- Code

Could you try that?


The first parameter given to a function connected to OnServerEvent is the player that fired the RemoteEvent. It is NOT a value that you give when firing the remote. So in your case, the function connected to the OnServerEvent will receive three values:

  • the player that fired the remote (Players.LocalPlayer in the local script)
  • the first value (Admin) given in the FireServer call
  • the second value (SubjectPlayer) given in the FireServer call

Since the function connected to OnServerEvent only has two parameters, the last value (SubjectPlayer) will not be used. The value of the parameter Admin is the player who fired the event and the value of the parameter Subject is the value that was called Admin in the LocalScript.

If Admin in the LocalScript is the LocalPlayer, just leave it out of the FireServer call. If not, then add a parameter to the connected function for the player who fired the event (this should be the first parameter).

I can’t think of a reason why the admin would not be the LocalPlayer, though. If it is the LocalPlayer, then the admin parameter of Commands["admin.kick"] is unnecessary as well.

Admin in Commands["admin.kick"] is apparently the same as Player in the code that handles the chat messages, so if this Player is always Players.LocalPlayer, then there’s no need to have the admin parameter in Commands["admin.kick"].


about the “User not found”, you might have entered the wrong name or you accidently pressed space 2 times. according to your code the Arguments is equal to message:split(" ") which may return: {"<the command>", "", "theplayername"}. also i dont recommend using GetDescendants to list players, since it will return all instances exist in Players. just use GetPlayers() and you are good to go.

1 Like

you can just do

game.Players[subject name ah]:Kick("Haha you suck L")
Events.KickPlayer.OnServerEvent:Connect(function( player, Admin, Subject)

the first argument is the player.


Admin is the player he just renamed it… (•_• )

1 Like

This may be an extremely stupid answer but have you tried doing

if SubjectPlayer.Name == Subject.Name

it could possibly be the answer but i have no idea if it is the right answer because im pretty sure even chatgpt could figure it out if it was that easy.

1 Like

No, this is the correct answer.
The server will always take .OnServerEvent:Connect(function(PlayerFired, param1, param2, ...)); however, in the OP’s post, the Local Script sends two arguments to the server :FireServer(Admin, SubjectPlayer), but the ServerScript also only has two parameters when it needs three. @Lion_Claac was correct.

Events.KickPlayer.OnServerEvent:Connect(function( player, Admin, Subject)
1 Like

I think you dont understand as well…
do you see these lines? according to them the Admin is our player and the Subject is the player to kick, ban e.t.c. Our original poster just renamed player to Admin.

1 Like

This is from the Roblox Wiki. Please read the blue text at the bottom.


I understand you completely but the thing is he renamed player variable to Admin. you know renaming? changing of name? he did exactly that. He knows that Admin is our player.

1 Like

He did not do that. If you look at line 19 in the first screenshot, the Local Script, he send (Admin, SubjectPlayer) and on line 6 of the second screenshot the server receives (Admin, Subject) which means that the Local Script sent TWO arguments and the server received TWO arguments NOT three. There is no renaming when there is not third parameter for the server to receive.

It needs to be (FiredUser, Admin, Subject)


Ohhh okay sorry my bad I didn’t see it (;‘-’ ). Sorry again.

all events fired from the client to the server have the first parameter being the player who fired the event

the client is firing the event passing in the parameters Admin and SubjectPlayer

BUT the server’s parameters are only Admin and Subject

since the first parameter of ANY event from the client to the server is the player who fired it. Admin is the player who fired it

and since the client passed in two arguments, now Subject is the player who ran the command because now its taking the arguments from the client

in short: change your on server event parameters to this
player, Admin, Subject

also, there is no need to loop through all of the players when you can just do

What are you trying to do even exactly? And why are you using remote events to kick?
also concat returns a string you might wanna use tostring(Player.UserId)
and if you’re trying to find players by partial string just use this

for _,v in game:GetService("Players"):GetPlayers() do
    if v.Name:sub(1,#arg) == arg then
       print(v.Name.." has similar phrase with arg")

I think you are over complicating the process, you can just add this script into ServerScriptService and thats it

-- !kick, dev_peashie, reason? cause yes... -- command

local admins = {1816810703} -- Admin IDs

local adminFuns = {
	["!kick"] = function(plrKick, msg)
		for _, p in pairs(game.Players:GetPlayers()) do
			if string.lower(p.Name) == plrKick then

		if table.find(admins, plr.UserId) then
			if string.sub(msg, 1, 1) == "!" then
				local theWarn = string.split(msg, ",")
				local split = string.split(string.gsub(string.lower(msg), "%s", ""), ",")

Its not optimized, I just typed it in a rush, but, it works.

Just type in chat:
!kick, playerName, reason


Have you tried doing

if SubjectPlayer.Name:lower() == Subject thrn

I noticed you set the message to lower, figured that might have something do with it.

1 Like

Many replies in this topic could “kinda make it work”, but anyone, honestly, think that the OP’s approach is the right one?.. From Client firing a Remote to send the data, validate it and kick the player?.. when its just a matter of connect the Chatted event from ServerSide on join, handle the check if its admin, call the function and thats it?

Are we trying to just fix the wrong approach? or can we just suggest a better one? as I tried in my reply…

1 Like

Getting it to work should be first priority, then rewriting should be second.