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

Would Using _G To Make A DataStore Table Be More Secure To Use?

Asked by
LuaDLL 253 Moderation Voter
5 years ago

If I use _G to make a table for all players to store data would that be more secure and prevent stat exploits?

Example:

local DataStore = game:GetService("DataStoreService"):GetDataStore("TEST")
local DataKey = "~~" --..UserId

_G["DataTable"] = {}

local DataTable = _G["DataTable"]

function Join(player)
    local UserId = player.UserId
    local Data = DataStore:GetAsync(DataKey..UserId)
    if Data then
        DataTable[player.UserId] = {}
        DataTable[player.UserId]["Stats"] = {}
        DataTable[player.UserId]["Stats"]["Money"] = Data[1]
    else
        DataTable[player.UserId] = {}
        DataTable[player.UserId]["Stats"] = {}
        DataTable[player.UserId]["Stats"]["Money"] = 2500
        DataStore:SetAsync(DataKey..UserId,{DataTable[player.UserId]["Stats"]["Money"]})
    end
end

function Leave(player)
    local UserId = player.UserId
    local PDataTable = DataTable[UserId]
    local Stats = PDataTable["Stats"]
    local Money = Stats["Money"]
    local Table = {Money}
    DataStore:SetAsync(DataKey..UserId,Table)
end

game.Players.PlayerAdded:Connect(Join)
game.Players.PlayerRemoving:Connect(Leave)

I would think it would be more secure seeing what _G is in the wiki.

1
No. don't use _G TheEpicObbyCreator 32 — 5y
1
Don't let the client have control of anything about the stats. Then it will be secure, that's all you need is to not trust the client to make it secure. if a client changes their stats locally it won't replicate to the server and it will see it as their old amount before exploiting. TheEpicObbyCreator 32 — 5y
0
^What he said Vulkarin 581 — 5y

Answer this question