#datastore is painful

184 messages · Page 1 of 1 (latest)

narrow drift
#

i wanna learn how to make datastores but i cant get it to work and i cant find a single good tutorial on youtube, please someone help me

rustic yacht
#

Ok

#

Sure no problem

#

@narrow drift

narrow drift
#

hey

rustic yacht
#

Good thing I made a video about it

narrow drift
#

thanks

rustic yacht
#

I dont have scripter role but still

#

I’m still good

narrow drift
#

oh thanks iil watch it and try to fix my code, thanks a lot!

rustic yacht
#

K

#

Let me explain little more

#

Data store

#

Your data is a array

#

Which means it’s {}

narrow drift
#

whats a array? i forgot

#

oh its like a table

#

ok got it

rustic yacht
#

Check the video

#

Tell me if u need help

narrow drift
#

ok, thanks

narrow drift
#

the video is just making a datastore it doesnt really explain what each part does

rustic yacht
#

Ik

narrow drift
#

so like if i want to make something different it couldnt if i only knew what was on the video

rustic yacht
#

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})

narrow drift
#

like i got a data for money and one for idk lvl

dusty wraith
#

i recommend you use a custom data module

sleek hazelBOT
#

studio** You are now Level 5! **studio

dusty wraith
#

use profileservice

narrow drift
#

i dont want to use it

#

i want to learn datastore

#

i know its better

#

and i will use it

rustic yacht
#

U can make a loop

narrow drift
#

but its good that i learn datastore too

rustic yacht
#

Or stuff

#

So

narrow drift
#

wdym

rustic yacht
#

For multi saving

#

Is simple

#

Let say ur data = (10,5)

dusty wraith
#

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.

rustic yacht
#

U can set your cash to cash = data[1] which is 10

#

The first to come in the array

dusty wraith
#

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.

narrow drift
#

docs are confusing

#

and there are like a gazzilion pages for datastore

#

on the docs

dusty wraith
#

Exactly why nobody really learns a lot about them and use modules from the people that did

rustic yacht
#

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

narrow drift
#

yeah the video doesnt really explain anything

#

if its the same way as the first one

#

you just do it

dusty wraith
narrow drift
#

@dusty wraith

dusty wraith
#

ty

rustic yacht
#

Bruh

#

Its bad quality

#

Pls no insult

dusty wraith
#

im not

#

and it's not bad quality, people can understand things differently

rustic yacht
#

I was going to delete the link

dusty wraith
#

why

rustic yacht
#

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

dusty wraith
#

i want to

smoky ridge
#

@narrow drift

#

Datastores are easy

#

want me to explain them to u?

narrow drift
#

please

smoky ridge
#

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

narrow drift
#

a

smoky ridge
#
local DataStore1 = DataStoreService:GetDataStore('Example_Name1')
local DataStore2 = DataStoreService:GetOrderedDataStore('Example_Name2')
#

imma just use 2

#

because idk much about the last one yet

narrow drift
#

if i had more it would be what

smoky ridge
#

GetDataStore initializes a datastore

narrow drift
#

getordereddatawhatever too?

smoky ridge
#

That's just for leaderboards and such

narrow drift
#

oh ok

smoky ridge
#

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)

narrow drift
#

oh ok

smoky ridge
#

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

narrow drift
#

datastore IS painful

smoky ridge
#

wat

#

it's just a big box 😭

narrow drift
#

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

smoky ridge
#

you don't gotta do allat

narrow drift
#

its so anoying 😭

smoky ridge
#

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

narrow drift
#

😭

smoky ridge
#
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

narrow drift
#

can i only store numbers or can i store more than that?

smoky ridge
#

if any

#

otherwise it will return nil

narrow drift
#

like instances or idk

narrow drift
#

strings

narrow drift
smoky ridge
#

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

narrow drift
#

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

smoky ridge
#

Just use ItemIDs

smoky ridge
#

set an ID for every item in your game

#

and store said ID in a table or something

narrow drift
#

what if the item has other shit inside it

#

like a tool that has scripts inside it

smoky ridge
#

you better have some alphanumeric identifier then

narrow drift
#

id have to clone all the scripts and parent them n shit

#

?

smoky ridge
#

yes

#

essentially, yes.

narrow drift
#

thats so anoying

smoky ridge
#

You get used to it after a bit

#

trust me, there are effecient ways to do nearly everything

narrow drift
#

datastore is painful

smoky ridge
#

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

narrow drift
#

ive been trying to learn it for almost a month and i cant get it to work 😭

smoky ridge
#

I can dumb it down even more if you need

narrow drift
#

its 11pm iil play smth and go to sleep then after school tomorrow iil take a better look

#

thanks a lot man