I’ve been experimenting with DataStore2 and I’ve been trying to come up with ways on how to create an independent table for the player and whether I’m on the right track or not.
On one of my previous posts, I was going to rely on the organization of folders within the Client and just leave it at that. But somebody pointed out it doesn’t seem very practical go along with that method. Additionally, the Client can exploit these values on their own if they were an exploiter.
So this time, I wanted to put everything in one table and so forth so it would be more secured in a sense:
ModuleScript
local PlayerDataMod = {
currencyTable = {
["Coins"] = 100,
["Gems"] = 25,
};
allitemsTable = {
"Default Emote",
"Default Vehicle",
};
}
return PlayerDataMod
(If not secured, just another obstacle a typical exploiter would have to jump through.)
However, when I moved onto the data script, I got… stumped.
DataScript
local ServerScriptService = game:GetService("ServerScriptService")
local Players = game:GetService("Players")
local DataStore2 = require(1936396537)
Players.PlayerAdded:Connect(function(player)
local PlayerDataModule = require(script.ModuleScript) --Confused/Stumped
local PlayerDataStore = DataStore2("UserData",player)
--?????
end)
The variable, PlayerDataModule
, the table I’m grabbing, I’m very confused by this and don’t understand what I’m doing.
When I’m requiring a table from a ModuleScript, is the table a created instance on its own, or is it just editing whatever is in the ModuleScript?
Obviously this script doesn’t save data, but I’m really clueless on what to do here. I’m having a difficult time of trying to figure out what to do next.