[SOLVED] Admin being not kicked himself [PATCHED]

Hello guys, so today, i just found a bug.

I just wanna to kick myself and it errors me.

LocalScript:

local Player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	print("You kicked "..script.Parent.Parent.Username.Text)
	if game.Players:FindFirstChild(script.Parent.Parent.Username.Text) then
		game.ReplicatedStorage.KickPlayer:FireServer(script.Parent.Parent.Username.Text, script.Parent.Parent.Reason.Text)
	end
end)

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Parent.Username.Text ~= game.Players.Name then
		warn("You are currently kicking an unknow username: "..script.Parent.Parent.Username.Text.." not founded.")
	end
end)

Script:

local Admins = {607908397, 2511060812} -- 607908397 = Cyril (kdopdaux1803) 2511060812 = 4667Hp
game.ReplicatedStorage.KickPlayer.OnServerEvent:Connect(function(Player, PlayerToKick)
	print("The UserId: " ..Player.UserId.." or the name of it: ".. PlayerToKick)
	if table.find(Admins, Player.UserId) and game.Players:FindFirstChild(PlayerToKick.Name) then
		PlayerToKick:Kick()
	end
end)

Video:

Output:

So yeah guys, any help is appreciated.

Maybe instead table.find add a loop trough the table of IDs?

Nope, it still errors me at the line 5…

I mean, it worked until line 5…

For this;

"or the name of it: ".. PlayerToKick)

You are trying to define only a instance in a concatenated string, it’s PlayerToKick.Name
Change line 3 to: print("The UserId: " ..Player.UserId.." or the name of it: ".. PlayerToKick.Name)

1 Like

Is the client script actually sending the player instance that is supposed to be kicked or only the name of that player? Because you are doing game.Players:FindFirstChild(PlayerToKick.Name), i believe you have the client send a player instance to the server. Is that correct? If not then just get rid of .Name

Can you send us the explorer of how this event is set up, and where it is being fired from?

On top of this,

Your code works for me:

1 Like

Wait What ??

For me it’s not working, somehow…

1 Like

Did you send a player instance via the remote event?

1 Like

It didn’t worked, instead it’s just errors me.

Can you send the script that fires the event?
So we can know what arguments are being passed.

1 Like
local Player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
	print("You kicked "..script.Parent.Parent.Username.Text)
	if game.Players:FindFirstChild(script.Parent.Parent.Username.Text) then
		game.ReplicatedStorage.KickPlayer:FireServer(script.Parent.Parent.Username.Text, script.Parent.Parent.Reason.Text)
	end
end)

-- Starting to here, you can ignore that.

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Parent.Username.Text ~= game.Players.Name then
		warn("You kicked an unknow username: "..script.Parent.Parent.Username.Text.." not founded.")
	end
end)

PlayerToKick:Kick()
‘PlayerToKick’ is a string value not a player instance.

Okay guys, it worked but it did not did the same reason of the TextBox…

You only accepted in 1 argument, (exclude Player since it is automatically passed in), which is PlayerToKick : string. You tried passing in 2 arguments in the client script, which the 2nd argument is Reason. You did not include that argument in the serverscript.

You can do this for the server script:

local Admins = {607908397, 2511060812} -- 607908397 = Cyril (kdopdaux1803) 2511060812 = 4667Hp
game.ReplicatedStorage.KickPlayer.OnServerEvent:Connect(function(Player, PlayerToKick, Reason)
	print("The UserId: " ..Player.UserId.." or the name of it: ".. PlayerToKick)
	if table.find(Admins, Player.UserId) and game.Players:FindFirstChild(PlayerToKick.Name) then
		PlayerToKick:Kick() -- handle the Reason arg, such as: PlayerToKick:Kick(Reason)
	end
end)
1 Like

I just found a soluton by myself…

local Player = game:GetService("Players").LocalPlayer
script.Parent.MouseButton1Click:Connect(function()
		print("You kicked "..script.Parent.Parent.Username.Text)
		if game.Players:FindFirstChild(script.Parent.Parent.Username.Text) then
			game.ReplicatedStorage.KickPlayer:FireServer(script.Parent.Parent.Username.Text, script.Parent.Parent.Reason.Text)
			game.Players.LocalPlayer:Kick(script.Parent.Parent.Reason.Text)
		
	end
end)

if script.Parent.Parent.Username.Text ~= game.Players.Name then
	warn("You kicked an unknow username: "..script.Parent.Parent.Username.Text.." not founded.")
end

The button wasen’t kicking someone at all…

Video:

@Pixelctrl, Thanks to try to help me.
@Forummer, Thanks to try to help me.

Guys, also, the admin cannot be kicked, anymore, because, i posted a topic about, and @SubtotalAnt8185 helped me to get an admin as an exepction to NOT being kicked at all…

Here’s the link of the topic: [SOLVED AT 50%] Username for short not cloning and the Admin being kicked as an exepction

And here’s the link of @SubtotalAnt8185’s post: [SOLVED AT 50%] Username for short not cloning and the Admin being kicked as an exepction - #44 by SubtotalAnt8185