#Data setup

1 messages · Page 1 of 1 (latest)

celest idol
#

how do people go about setting up data like in type soul how would you set up like which weapon that player has and then like more obscure things like if you open a certain door in the game how do you data save if you every opened that door. finally, with setting up data should tables be used?

steep geyser
#

for example one table could be leaderstats, and another could be tools

celest idol
#

o so like one main player data table then alot of tables inside and if so were do you make the tables?

#

@steep geyser

steep geyser
#

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.

celest idol
#

do you make this table on join and how would other things inside the game get that tables data?

#

@steep geyser

steep geyser
#

making it a dictionary is better than an array so you can call for the different stuff easier

celest idol
steep geyser
celest idol
#

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?

sinful marlin
#

words have to be in "" no?

celest idol
#

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

sinful marlin
#

oh i see

#

theres multiple "table" like data structures in lua??

#

i thought it was only tables?