I’m making an admin panel and I’m wondering how I could make a GUI button that bans a user.
^ I’m kind of going for something like my kicking button except it bans. Can someone explain how I can make one?
I’m making an admin panel and I’m wondering how I could make a GUI button that bans a user.
there’s currently no way to ban anybody yet but you can kick them permanently (Or for a given time) which acts as a ban. You could use something like this?
game.Players.PlayerAdded:Connect(function(Player)
if Player.Name == 'Player1' then
Player:Kick('Your Reason for ban')
end
end)
If you are wanting to ban the player from a control panel then You should be using datastores (i think)
You need to use DataStores to achieve this. If your going to ban players, it’s better to use their UserIDs as they can easily just change their Username if your ban system saves it by their Names.
Also, there are tons of posts about this specific topic. Make sure to use the Search Feature before creating topics as someone could’ve already found the answer you’ve been looking for!
Hello @BlueExplosion8!
In order to do this, I personally would make a LocalScript inside the button, listen for when the button is pressed (Button.MouseButton1Click:Connect()
), check if the “Insert Username” part has a valid Username inserted into it, and if there is a valid username inserted then Fire to the server using a RemoteEvent.
Once done so, I would listen for the RemoteEvent using Event.OnServerEvent:Connect()
and then check if the Player that fired it has permission. Now, the reason as to why we check it on the server is because if you check it on the Client, then your RemoteEvent could be tampered with easily by Exploiters and all hell could break lose if the Exploiter has access to your GUI without proper permissions, BUT, if you check it on the Server, then they shouldn’t be able to tamper with the functions on the Server. Be sure to also check if the given Player to ban exists on the Server as well.
If the Player that fired the RemoteEvent has permission (you can use a DataStore to store permissions), then follow through with the ban function, adding the given Player to a ban DataStore and kick them from the Server. Additionally, you will have to add another listener to detect when a Player joins, check the ban DataStore and if they are on the ban DataStore then kick them from the server.
Let me know if this helped. I apologise in advance if this is confusing, let me know if it is and what I can explain more in depth if you get stuck and I will be more than happy to help.
Cheers and take care,
Bruce