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)
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)
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
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)
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)
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
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…