i tried to do a kick gui but it not work script:
script.Parent.Frame.TextButton.MouseButton1Click:Connect(function()
local playertokick = game.Players:FindFirstChild(script.Parent.Frame.TextButton.Text)
playertokick:Kick()
end)
i tried to do a kick gui but it not work script:
script.Parent.Frame.TextButton.MouseButton1Click:Connect(function()
local playertokick = game.Players:FindFirstChild(script.Parent.Frame.TextButton.Text)
playertokick:Kick()
end)
Hello. The Client cannot kick other players. To do that from a GUI you have to send the data (player name in this case and the reason if you want) through a RemoteEvent. Make sure you have some checks on the server, I mean only certain players can kick other players. If you don't then any exploiter can kick anyone. So here is what I have done:
-- LocalScript
script.Parent.Frame.SubmitButton.MouseButton1Click:Connect(function()
local Username = script.Parent.Frame.Username.Text
local Reason = script.Parent.Frame.Reason.Text
game.ReplicatedStorage.RemoteEvent:FireServer(Username,Reason)
end)
When the TextButton/ImageButton is clicked, It will send the text from the TextBox(Username and Reason) to the server through the RemoteEvent.
-- Script
local Allowed = {
["JakyeRU"] = true, -- Can Kick
["Player1"] = true, -- Can Kick
["Player2"] = true, -- Can Kick
["Player3"] = false -- Can't kick
} -- Everyone else who is not in this table can't kick
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(PlayerWhoFired, UsernameToKick, ReasonForKick)
if Allowed[PlayerWhoFired.Name] and game.Players:FindFirstChild(UsernameToKick) then
game.Players[UsernameToKick]:Kick(ReasonForKick)
end
end)
The Allowed Table stores the players who can kick other players. So you don't have to worry if an exploiter get the Admin GUI and tries to kick someone. Remember, always use Server checks. Then, when the event is fired from the client, it will check if the player who fired it is in that table (has access to kick others) and if the player is in game.
This discussion is preserved as it was. New answers, comments, and votes are closed.
1 comment
*And if the player you want to kick is in the game.