8/19/2023 0 Comments Roblox kick and ban logPlayers.PlayerAdded:Connect(function(player) If it is we will want to split the string (to get the player to kicks name as the command will be called using “/ban playersName”), Check if the player is a valid player and then if they are then set their saved ban value to true and kick them. If they are an admin we will setup a chatted event that gets the message they said: Players.PlayerAdded:Connect(function(player)Īfter that we will want to see if “/ban” is in the message: Players.PlayerAdded:Connect(function(player) For me it will look like this (as I will be the only admin I only need to check if the player is me by using my player id) Players.PlayerAdded:Connect(function(player) So what you will want to do is check if they (the person who joined) are an admin, make sure you use their userId instead of their username as their username can change at anytime unlike their userId. Next we will add an else statement to give the default value (false) if no value was found in the data store Players.PlayerAdded:Connect(function(player)Īlright we are done with the datastore, now we will make the way the player will get banned (which will be through an admin command /ban plrName ) Player:Kick("You are banned from this game!") Next we want to check if the pcall was successful with retrieving the data, if so we will want to check if the stored value is true, if so then kick the player and tell them they are banned from the game! Players.PlayerAdded:Connect(function(player) Return DS:GetAsync(plr_key) - Get Values From DataStore Players.PlayerAdded:Connect(function(player)Īfter That we will want to get the key we will be using for the data store and check if there is a value saved in the datastore using a pcall function: Players.PlayerAdded:Connect(function(player) Next we will add a player added function and get the player from it local DS = game:GetService("DataStoreService"):GetDataStore("BanDataStore") Local Players = game:GetService("Players") I’ll call the script “Ban” in the script we will set up a A few service variables first: local DS = game:GetService("DataStoreService"):GetDataStore("BanDataStore") Tutorial has been updated to follow suggestions made by to get started open the world you want to add this to and insert a script in ServerScriptService This tutorial will cover how to make a very basic ban system I will show you how to make a perma ban (permanent ban) system/command. I know there may have been posts regarding how to make a ban system but I wanted to make it easier for the community to find.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |