First post here, anyways…
I’ve been trying to make an Anticheat for my games, and making a module for a ban system. I’ve been having some issues with said module…
I had a friend help with it, but it still doesn’t work.
The said script/module:
local DataStoreService = game:GetService("DataStoreService")
local BanDS = DataStoreService:GetDataStore("SingularityBans")
local RepStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local CachedData = {}
Players.PlayerAdded:Connect(function(Plr)
local Key = tostring("User_"..Plr.UserId)
local Table
local success, err = pcall(function()
Table = BanDS:GetAsync(Key) or {}
end)
if not Table.BanInfo then
Table.BanInfo = {
IsBanned = true;
Reason = "No Reason";
}
end
if success then
CachedData[tostring(Plr.UserId)] = Table
if Table.BanInfo.IsBanned then
Plr:Kick(Table.BanInfo.Reason)
end
else
warn("Error Detected In Singularity Ban Module!")
end
end)
Players.PlayerRemoving:Connect(function(Plr)
if CachedData[tostring(Plr.UserId)] then
local success, err = pcall(function()
BanDS:SetAsync(Plr.UserId, CachedData[tostring(Plr.UserId)])
end)
if err then
warn(string.format("SetAsync Failed. (%s)", err))
end
end
end)
RepStorage.Remotes.Events.SingularityReciever.OnServerEvent:Connect(function(Plr:Player,Table:{IsBanned:boolean,Reason:string})
CachedData[tostring(Plr.UserId)] = Table
Plr:Kick(Table.Reason)
end)