Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Making A Table That Stores Banned People?

Asked by
fff054 51
5 years ago

So, I'm Making A Ban Hammer And I Want To Add People To A Table In Which They'll Be Kicked Out. I'm Trying To Store The Table In Datastore2, But I Have No Clue Of How To Do It. Also, I Need To Update The Table Every Time Someone Gets Banned. I Know It Sound Kinda Simple, But I'm Really Struggling With It. I've Tried With Data Store (The One That Roblox Brings) Because I Thought It'll Be Easier And Now I Know It Wasn't.

Here Is The Last Version Of My Code, In Which I Didn't Succeed :/

01--// Ban Data Store \\--
02local BannedList = {410710393}
03 
04local RealBannedList = {}
05 
06pcall(function()
07    if game:GetService('DataStoreService'):GetDataStore('BannedPeople'):GetAsync('ABannedList') then
08        return
09    else
10    local Data = game:GetService('DataStoreService'):GetDataStore('BannedPeople'):SetAsync('ABannedList',RealBannedList)
11    local Table = game:GetService('DataStoreService'):GetDataStore('BannedPeople'):GetAsync('ABannedList')
12    end
13end)
14 
15local Table = game:GetService('DataStoreService'):GetDataStore('BannedPeople'):GetAsync('ABannedList')
View all 37 lines...
0
From what I've heard and done, using the ROBLOX DataStore to store tables is easier than DataStore2. killerbrenden 1537 — 5y
0
Ik, but it still doesn't work :/ fff054 51 — 5y

1 answer

Log in to vote
1
Answered by 5 years ago
Edited 5 years ago

I got my own anti-cheat in a project of mine and I utilize DSS as well. I use two seperate scripts to achieve this, but you could most likely use one.

01--DataStorage Script
02local DSS = game:GetService("DataStoreService")
03local MDS = DSS:GetDataStore("MDS")
04 
05game.Players.PlayerAdded:Connect(function(plr)
06    local data = Instance.new("Folder")
07    data.Name = "PlayerData"
08    data.Parent = plr
09 
10    local banned = Instance.new("BoolValue")
11    banned.Name = "isBanned"
12    banned.Parent = data
13 
14    local money = Instance.new("IntValue")
15    money.Name = "Cash Money"
View all 52 lines...
01--Second script.
02local Banned = {}
03local Favorites = {1348670747,}
04game.Players.PlayerAdded:Connect(function(plr)
05    local PlayerData = plr:WaitForChild("PlayerData")
06    for i, b in ipairs(Banned) do
07        if b == plr.UserId then
08            plr:Kick("You're not welcome here.")
09            print(plr.Name.. " was kicked.")
10        end
11    end
12    for i, b in ipairs(Favorites) do
13        if b == plr.UserId then
14            print(plr.Name.. ".")
15        end
View all 24 lines...

So how does it work? Whenever a play joins the game, a folder called "PlayerData" is inserted into the instance, where it keeps track of their banned state, and money in my case. If my anti-cheat catches a player, it ticks off their 'banned' bool as true, then kicking them. If they dare to rejoin, it checks if they're banned and if so, it kicks them. In your case, you can make it so that when you hit the player with your ban hammer, it gets the player from the character, turns the banned bool to true, and kick them. Edit: Remember that I used DataStoreService, but you could probably use DS2.

Ad

Answer this question