I’m making an automatic anti-exploit system, when someone fires a remote that they shouldn’t, they get banned. My datastore contains a table with all datastore information.
Datatable[1] is the reason why someone is banned, if it’s nil, then the player is not banned.
Here’s my script:
local dss = game:GetService("DataStoreService")
local tablestore = dss:GetDataStore("HML2_Table")
-- table_order = {BanReason,Value,Value,Value,Value,Value}
local default_table = {nil,0,0,0,0,0}
game.Players.PlayerAdded:Connect(function(plr)
local plrInfoTable = tablestore:GetAsync(plr.UserId) or default_table
print(plrInfoTable)
if plrInfoTable[1] ~= nil then
plr:Kick(plrInfoTable[1])
end
end)
game.ReplicatedStorage.Project_Stainless.ReplicateGlobalBan.Event:Connect(function(target,reason)
local plrInfoTable = tablestore:GetAsync(target.UserId)
print(plrInfoTable)
--plrInfoTable[1] = reason
--tablestore:SetAsync(target.UserId,reason)
game.ReplicatedStorage.BanClient:FireClient(target)
wait(.1)
target:Kick(reason)
end)
(BanClient remote plays evil morty for the client)
For some reason the first time (PlayerAdded) everything prints as it should [table complex_code].
But when I ban a player, or test the banning system, the same piece of code returns nil.
Why is this?