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.
02 | local DSS = game:GetService( "DataStoreService" ) |
03 | local MDS = DSS:GetDataStore( "MDS" ) |
05 | game.Players.PlayerAdded:Connect( function (plr) |
06 | local data = Instance.new( "Folder" ) |
07 | data.Name = "PlayerData" |
10 | local banned = Instance.new( "BoolValue" ) |
11 | banned.Name = "isBanned" |
14 | local money = Instance.new( "IntValue" ) |
15 | money.Name = "Cash Money" |
21 | local success, errormsg = pcall ( function () |
22 | Banneddata = MDS:GetAsync(plr.UserId.. "-isBanned" ) |
23 | Moneydata = MDS:GetAsync(plr.UserId.. "-Money" ) |
27 | banned.Value = Banneddata |
28 | money.Value = Moneydata |
29 | if banned.Value = = true then |
30 | plr:Kick( "You're not welcome here." ) |
33 | print ( "There was an error while recovering " .. plr.Name.. "'s data..." ) |
38 | game.Players.PlayerRemoving:Connect( function (plr) |
40 | local success, errormsg = pcall ( function () |
41 | MDS:SetAsync(plr.UserId.. "-isBanned" , plr.PlayerData.isBanned.Value) |
42 | MDS:SetAsync(plr.UserId.. "-Money" , plr.PlayerData [ "Cash Money" ] .Value) |
46 | print (plr.Name.. "'s data was saved." ) |
48 | print (plr.Name.. "'s data was not saved due to an error." ) |
03 | local Favorites = { 1348670747 , } |
04 | game.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." ) |
12 | for i, b in ipairs (Favorites) do |
13 | if b = = plr.UserId then |
17 | if plr.PlayerData.isBanned.Value = = true then |
18 | plr:Kick( "You're not welcome here." ) |
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.