#datastore is painful
184 messages · Page 1 of 1 (latest)
hey
Good thing I made a video about it
thanks
oh thanks iil watch it and try to fix my code, thanks a lot!
K
Let me explain little more
Data store
Your data is a array
Which means it’s {}
ok, thanks
i mean, it works but i didnt quite like understand how to make it
the video is just making a datastore it doesnt really explain what each part does
Ik
so like if i want to make something different it couldnt if i only knew what was on the video
U see
My laptop is shit
My ping is 900
Idk how to edit good
And its laggy most of the time so I don’t record often
Data store uses
Asnyc or whatever
Get and set
When player first join they don’t have data so you set it
To get data you do data = da:getasync(player.userid)
To set it when they first join
Just do ds:setasync(player.userid,0)
To set it when player leaves just do ds:setasync(player.userid,{your saving value here})
what if there are more than one single data on that players id
like i got a data for money and one for idk lvl
i recommend you use a custom data module
** You are now Level 5! **
use profileservice
i know abt profileservice
i dont want to use it
i want to learn datastore
i know its better
and i will use it
U can make a loop
but its good that i learn datastore too
wdym
Okay, well you can learn the basic methods, but there is a lot of variables to consider when handling data and it's better to just use a custom data module.
Read documentation on the data store, as well as watch youtube tutorials on how to secure data and whatnot as well as aread the dev forum.
docs are confusing
and there are like a gazzilion pages for datastore
on the docs
Exactly why nobody really learns a lot about them and use modules from the people that did
E
I made a video of using module script to save data
U can check it out btw @narrow drift u probably can’t understand
yeah the video doesnt really explain anything
if its the same way as the first one
you just do it
wheres ur yt channel connection
@dusty wraith
ty
I was going to delete the link
why
Bc why not
No one watch it anyways
I just do it for fun
Maybe if I forget how to script
With 3-4 years of experience
I have goldfish memory
i want to
please
Ok
So
lemme write an example rq
local DataStores = {}
local DataStoreService = Game:GetService('DataStoreService')
return DataStores
the service itself
very simple
next up
we have the actual datastores
You can use one of i think 3 methods
a
local DataStore1 = DataStoreService:GetDataStore('Example_Name1')
local DataStore2 = DataStoreService:GetOrderedDataStore('Example_Name2')
imma just use 2
because idk much about the last one yet
if i had more it would be what
GetDataStore initializes a datastore
getordereddatawhatever too?
That's just for leaderboards and such
oh ok
start with regular GetDataStore
You have the name 'Example_Name1'
meaning that datastore is not initialized when the game runs
(this is a module script so no it wont until the module is required)
oh ok
right
so
thats MAKING a datastore
but
said store has no data in it or nothing
So lemme make another example
local DataStoreService = Game:GetService('DataStoreService')
local PlayerInventory = DataStoreService:GetDataStore('PlayerInventory')
local Coins = DataStoreService:GetDataStore('PlayerInventory', 'Coins')
local Gems = DataStoreService:GetDataStore('PlayerInventory', 'Gems')
Now our datastore has what's called 'scopes'
essentially lets think of them as little areas in a box
we have a big box we call a datastore, meant to hold data, that box has segments/sections called scopes that hold specific data, these scopes ARE optional, however you will need them in most cases for organizing said box.
But again, now we have a box with segments/sections, still no data
datastore IS painful
its painful
to make
it may be a big box
but u gotta process the tree into paper
to make cardboard
then shape it into the box
then cut it
to make the box
you don't gotta do allat
its so anoying 😭
You just gotta grab the box materials via DataStoreService, get the box you want with :GetDataStore and seperate the box into segments using scopes
3 steps
as for data, i'm getting to that
THAT is the hard part
even though it's easy
😭
local DataStoreService = game:GetService('DataStoreService')
local PlayerInventory = DataStoreService:GetDataStore('PlayerInventory')
local Coins = DataStoreService:GetDataStore('PlayerInventory', 'Coins')
local Gems = DataStoreService:GetDataStore('PlayerInventory', 'Gems')
local Key = 'InsertUserIDHere'
Coins:SetAsync(Key, 1)
print(Coins:GetAsync(Key))
So now we have Coins:SetAsync()
It's rather straightforward, just remove the 'Async' part from datastores and it makes things a lot easier to understand
You're just Setting data for a certain Key, a key should normally be a userid, though it can be any alphanumeric string
get, it's just getting the data that's been set
can i only store numbers or can i store more than that?
like instances or idk
Values
strings
oh
No, You can store strings, numbers, booleans, nil, and tables if you do some json shenanigans
that's where the pain comes in
you also have IncrementAsync, that simply adds on or takes away from an already set value
so i assume that like if i want to store a tool i gotta check if the data has it then if it does clone the tool to players inv or smth?
that sounds so anoying
Just use ItemIDs
oh
you better have some alphanumeric identifier then
thats so anoying
You get used to it after a bit
trust me, there are effecient ways to do nearly everything
datastore is painful
it is for the first few days, i'll admit
don't get me started on DataStorePages, you don't even get autofill for half of that stuff
but that's more advanced
ive been trying to learn it for almost a month and i cant get it to work 😭
I can dumb it down even more if you need