Anti-Exploit (Server Script)
--- Cardinal - The program that overlooked SAO
--- Cardinal Set Up
local CardinalSetUp = {}
CardinalSetUp[1] = script:WaitForChild("SpeedLimitEnabled")
CardinalSetUp[2] = script:WaitForChild("SpeedLimit")
--- Create Cardinal Event
local CardinalEvent = Instance.new("RemoteEvent")
CardinalEvent.Parent = game.ReplicatedStorage
CardinalEvent.Name = "CardinalEvent"
--- Modules
local DSS3Module = require(game.Workspace.Modules.DSS3Module)
local TimeAndDateMod = require(game.Workspace.Modules.TimeAndDateMod)
local StatsModule = require(game.Workspace.Modules.StatsModule)
function BanPlayer(Player,Duration,Reason)
if not Reason then
Reason = "No Reason Provided"
end
DSS3Module.SetData("CardinalBans",tostring(Player.UserId), tostring(Duration) .. ";Split; " .. Reason)
end
game.Players.PlayerAdded:Connect(function(NewPlayer)
local Ban = {}
Ban[1] = DSS3Module.GetData("CardinalBans",tostring(NewPlayer.UserId))
if Ban[1] == nil then --or NewPlayer.UserId == 58666138
-- Player Is Not Banned
else
if string.split(Ban[1],";Split;")[1] == "inf" then
NewPlayer:Kick("Banned For Eternity For:" .. string.split(Ban[1],";Split;")[2])
else
if tonumber(string.split(Ban[1],";Split;")[1]) - os.time() > 0 then
NewPlayer:Kick("Time Left On Ban: " .. tostring((tonumber(string.split(Ban[1],";Split;")[1]) - os.time()) / 60) .. " Minutes")
else
DSS3Module.RemoveData("CardinalBans",tostring(NewPlayer.UserId))
end
end
end
local SpeedCoroutine = coroutine.create(function()
local PreviousPosition = {}
while CardinalSetUp[1].Value == true do -- Alternative to using a coroutine (Can be immediatly stopped)
if game:GetService("Players"):FindFirstChild(NewPlayer.Name) then
wait(1)
if NewPlayer.Character then
if PreviousPosition[1] then
if (NewPlayer.Character.Torso.CFrame.Position - PreviousPosition[1].Position).Magnitude > CardinalSetUp[2].Value then
print("Speed Triggered")
if NewPlayer:FindFirstChild("Teleporting") then
wait(1)
PreviousPosition[1] = NewPlayer.Character:FindFirstChild("Humanoid").CFrame
else
NewPlayer.Character:FindFirstChild("Torso").CFrame = PreviousPosition[1]
end
end
end
PreviousPosition[1] = NewPlayer.Character:FindFirstChild("Torso").CFrame
end
else
break -- Player Has left the game
end
wait(1) -- Prevents lag and is set to 1 to get distance per second
end
end)
coroutine.resume(SpeedCoroutine)
end)
--- Cardinal Event
CardinalEvent.OnServerEvent:Connect(function(Player, Data)
local EventProccessed = false
----- Change EventProccessed upon event completion
----- Pcall to prevent bans on errors
local Success, msg = pcall(function()
---- Blank fires result in banning the player
if Data == "" then
BanPlayer(Player,"inf","You got banned by the Cardinal System for one of the following reasons: Firing Remotes, Unautharised Module Access or Workspace Exploitation")
EventProccessed = true
end
---- Cardinal Admin Use
if Player.UserId == 58666138 then
if Data[1] == "Ban" then
if Data[2] == nil then
Data[2] = "inf"
end
BanPlayer(Data[4],Data[2],Data[3])
EventProccessed = true
end
end
end)
------
if Success == nil and msg then
EventProccessed = true
print("Server Sided Error, printing diagnostics. \n " .. msg)
end
------
if EventProccessed == false then
-- Ban Player
BanPlayer(Player,"inf","You got banned by the Cardinal System for one of the following reasons: Firing Remotes, Unautharised Module Access or Workspace Exploitation")
end
end)
The Idea of this is to prevent people going to fast or teleporting by any means. This also handles bans and I hope also bans players trying to access my RemoteEvents. And yes I named it Cardinal from SAO
DSS3 (Module Script)
local DSS3 = {}
local DataStoreService = game:GetService("DataStoreService")
local RunService = game:GetService("RunService")
---- Cardinal Event (Big Brain Game Security)
local CardinalEvent = game.ReplicatedStorage:WaitForChild("CardinalEvent")
---- Ban If Running On Client
if RunService:IsClient() then
CardinalEvent:FireServer() -- Blank Remote Fire Resulting In A Ban
end
----------------------------------------- // Base Functions (Save, Load, Update, Remove, CheckForData)
function DSS3.SetData(Store,Player,Data)
for i = 1,10 do
local S, R = pcall(function()
local NewStore = DataStoreService:GetDataStore(Store)
NewStore:SetAsync(Player,Data)
end)
if S then
print("Set Data")
break
else
print("DSS Error:")
print(R)
wait(2)
end
end
end
function DSS3.UpData(Store,Player,Data)
for i = 1,10 do
local S, R = pcall(function()
local NewStore = DataStoreService:GetDataStore(Store)
NewStore:UpdateAsync(Player,Data)
end)
if S then
break
else
print("DSS Error:")
print(R)
wait(2)
end
end
end
function DSS3.GetData(Store,Player)
local Result
for i = 1,10 do
local S, R = pcall(function()
local NewStore = DataStoreService:GetDataStore(Store)
Result = NewStore:GetAsync(Player)
end)
if S then
return Result
else
print("DSS Error:")
print(R)
wait(2)
end
end
end
function DSS3.RemoveData(Store,Player)
for i = 1,10 do
local S, R = pcall(function()
local NewStore = DataStoreService:GetDataStore(Store)
NewStore:RemoveAsync(Player)
end)
if S then
print("Removed Data")
break
else
print("DSS Error:")
print(R)
wait(2)
end
end
end
function DSS3.CheckForExistingData(Store,Player)
local Data
for i = 1,#3 do
local S, R = pcall(function()
Data = DSS3.GetData(Store,Player)
if Data == nil then
local Result = false
return Result
else
end
end)
wait(1)
if S then
break
end
end
if Data == nil then
local Result = true
return Result
end
end
----------------------------------------- // ArraySaving, ArrayLoading
function DSS3.SaveArray(Store,Player,Data)
local Combined = table.concat(Data,";Split;")
DSS3.SetData(Store,Player,Data)
end
function DSS3.LoadArray(Store,Player)
return string.split(DSS3.GetData(Store,Player),";Split;")
end
----------------------------------------- // DataStore Listing (For BackUps or Databases)
function DSS3.CreateListing(Store,Data)
for i = 1,10 do
local S, R = pcall(function()
local EntryCount = DSS3.GetData(Store .. "EntryCount","EntryCount")
if tonumber(EntryCount) == nil then
EntryCount = 0
end
EntryCount = tostring(tonumber(EntryCount) + 1)
DSS3.SetData(Store,EntryCount,Data)
DSS3.SetData(Store .. "EntryCount","EntryCount",EntryCount)
end)
if S then
break
else
print("DSS Error:")
print(R)
wait(2)
end
end
end
function DSS3.GetListings(Store)
local StoreNames = {}
for i = 1,10 do
local S, R = pcall(function()
local EntryCount = DSS3.GetData(Store .. "EntryCount","EntryCount")
EntryCount = tonumber(EntryCount)
StoreNames = {}
for i = 1, EntryCount do
local Name = tostring(i)
table.insert(StoreNames,Name)
end
end)
if S then
return StoreNames
else
print("DSS Error:")
print(R)
wait(2)
end
end
end
function DSS3.RemoveListing(Store,Number)
DSS3.SetData(Store,Number,nil)
end
function DSS3.GetEntryCount(Store)
local EntryCount = DSS3.GetData(Store .. "EntryCount","EntryCount")
EntryCount = tonumber(EntryCount)
return EntryCount
end
----------------------------------------- // Save Or Load Models (Via My Modules)
local PartSavingMod = require(script.PartSavingModule)
function DSS3.SaveModel(Model)
return PartSavingMod.GetModelProperties(Model)
end
local PartLoadMod = require(script.PartLoadingModule)
function DSS3.LoadModel(Model)
return PartLoadMod.LoadModel(Model)
end
----------------------------------------- // Time And Date
local TimeAndDateMod = require(script.TimeAndDateMod)
function DSS3.GetSecondsPassed()
return TimeAndDateMod.SecondTime()
end
----------------------------------------- // GetBackup Data
function DSS3.GetBackup(Store)
print("Attempting To Get Backup Data from" .. Store)
local Backups = DSS3.GetListings(Store)
local Data = {}
Data[1] = #Backups
while not Data[3] == nil do
Data[2] = DSS3.GetData(Backups[Data[1]])
if Data[2] == nil then
-- Data May Be Corrupted
Data[1] = Data[1] - 1
else
Data[3] = Data[2]
end
end
if Data[3] then
return Data[3]
else
print("No Usable Backups Found")
end
end
----------------------------------------- // Returns The DSS3 Module
return DSS3
DSS3 is my own DataStoreScript that BacksUp data and allows me to store a mass of data that is organised by the date it was saved. Runs as a module and if anyone tried to run it on the client it sends a black fire to Cardinal resulting in a instant ban. Can also turn workspace models into text so I can save them.