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.