#Data setup
1 messages · Page 1 of 1 (latest)
my game uses tables inside of a giant table which is saved under a key of the players id
for example one table could be leaderstats, and another could be tools
o so like one main player data table then alot of tables inside and if so were do you make the tables?
@steep geyser
i have one data table called "players data"
i then have a table which is all the players data. I usually then have multiple tables inside of that table for organizing the data.
do you make this table on join and how would other things inside the game get that tables data?
@steep geyser
when the player joins simply get this table with all the players data and whenever you need it just reference for the thing inside the table.
making it a dictionary is better than an array so you can call for the different stuff easier
could you give me an example rq?
alr one sec
kk
local DatastoreService = game:GetService("DataStoreService")
local PlayerDataStore = DatastoreService:GetDataStore("PlayerData")
local PlayersData = {}
local DataSetup = {}
function DataSetup.CreateData(UserId)
local PlayerData = {
Combat = {Weapon = "None", Health = 100, Posture = 100},
Inventory = {},
Talents= {},
Misc = {},
}
end
return DataSetup
@steep geyser prob sum like this?
does that work?? the syntax doesnt look right
words have to be in "" no?
no cus its in a dictinary
ii changed it a bit now
local DatastoreService = game:GetService("DataStoreService")
local PlayerDataStore = DatastoreService:GetDataStore("PlayerData")
local PlayersData = {}
local DataSetup = {}
function DataSetup.CreateData(UserId)
local PlayerData = {
PlayerId = UserId,
Combat = {Weapon = "Fists", Health = 100, Posture = 0},
CommonKeybinds = {Dash = "Q", M1 = "Mouse1", Block = "F", Parry = "Mouse2"},
Inventory = {},
Talents= {},
Misc = {},
}
table.insert(PlayersData, PlayerData)
return PlayerData
end
function DataSetup.GetData(UserId)
for i, Data in pairs(PlayersData) do
if Data.PlayerId == UserId then
return Data
else
warn("There Is NO DATA for player")
end
end
end
return DataSetup