#am i doing this datastore right? QwQ

1 messages · Page 1 of 1 (latest)

fringe thicket
#

i made a lil datastore for smth, but im not sure if im doing it right, i tried looking up if i am, but i just couldnt tell :P

local DataStoreService = game:GetService("DataStoreService")

local CharactersOwned = DataStoreService:GetDataStore("CharactersOwnedStore") -- Create a DataStore

local getCharactersOwned = game:GetService("ReplicatedStorage"):WaitForChild("RemoteFunctions"):WaitForChild("GetCharactersOwned")
local insertCharacterOwned = game:GetService("ReplicatedStorage"):WaitForChild("RemoteEvents"):WaitForChild("InsertCharacterOwned")

game.Players.PlayerAdded:Connect(function(player)
    -- Load player data
    local savedCharactersOwned = CharactersOwned:GetAsync(player.UserId) or {}
end)

game.Players.PlayerRemoving:Connect(function(player) 
    local savedCharactersOwned = CharactersOwned:GetAsync(player.UserId) or {}

    CharactersOwned:SetAsync(player.UserId, savedCharactersOwned)
end)

getCharactersOwned.OnServerInvoke = function(player)
    local savedCharactersOwned = CharactersOwned:GetAsync(player.UserId) or {}

    return savedCharactersOwned
end

insertCharacterOwned.OnServerEvent:Connect(function(player, char)
    local savedCharactersOwned = CharactersOwned:GetAsync(player.UserId) or {}

    table.insert(savedCharactersOwned, char)

    CharactersOwned:SetAsync(player.UserId, savedCharactersOwned)
end)
fringe thicket
#

yupperz

full dove
#

the script like does basically nothing

#

it grabs stuff but doesnt store it anywhere so it just dissapears

#

among other things

#

im being very unhelpful im sorry but genuinely youll have better chances just rewriting the script 😓

fickle spire
#

✌️😭

#

did chatgpt write ts

fringe thicket
#

no...

#

well it seems to work, like the characters owned works...

fickle spire
#

what is your goal for the script

inland widget
#

yes

#

i mean

#

yessnt

inland widget
latent mango
inland widget
latent mango
inland widget
#

bruh

#

just use ps

#

im just saying that for beginners

#

they need to learn basic datastore first

#

understand?

latent mango
#

Nah making your own data store is very risky if you are making a game for beginners so I wouldnt suggest it and profile store has guaranteed saving so you can always expect saved data

latent mango
#

bro what

inland widget
#

data store is not risky

latent mango
latent mango
inland widget
inland widget
#

🤑

#

!rank

remote hingeBOT
inland widget
#

yes

#

ALMOST

#

SO CLOSE

latent mango
inland widget
#

for beginners they need to learn

#

thats the whole point

#

of scripting

#

its not to create a good game

#

its to learn something

#

not be a npc

#

push out some steal a brainrot game

latent mango
#

Alright but it isnt rlly save to make your own data store just saying

inland widget
#

idk about you but i learn it for mone- i mean for fun

latent mango
#

I rather be safe than sorry to be publishing an successful game and all the data gets wiped for some unknown reason

latent mango
#

(Happened to my last game)

inland widget
#

but what are the chances a beginner can make a whole game in the first place

#

let alone successful

inland widget
latent mango
#

ik i thought I had the data store under control but when players started rolling new players had other players data cuz i didnt decompile the data store

#

wasnt rlly the best datastore

#

thats y i use profile store from now on

inland widget
inland widget
fickle spire
#

in your case it looks like new players shared a data table model? idk what you mean by decompile the table cuz that would normally jst be transforming the values into a form that can be input into the set async function

inland widget
#

regular is just for beginners to try out

#

can you chill

fringe thicket
#

ill try profile store :3

quartz harbor
#

No one be talking abt Suphi's Datastore

wise apex
#

both are acceptable terms for sterilization, just using serialization as the term makes more sense.

wise apex
quartz harbor
quartz harbor
wise apex
#

Yesnt

#

This right the datastore that hasn't been updated since 2023

true obsidian
#

but at least he is learning but still suphis oh bruh

ornate steeple
ornate steeple
ornate steeple
ornate steeple
ornate steeple
#

hope that clears up some confusion in here Thumbs

quartz harbor
ornate steeple
quartz harbor
#

profilestore uses the same thing basically

ornate steeple
#

profilestore uses messagingservice, the lock can be in a datastore you dont need memorystore its just wasted quota

#

i suppose we can add that to the list of reasons why profilestore is objectively better than suphi's datastore: it doesn't waste memorystore quota on useless things

#

i'd also wager you don't know why profilestore has messagingservice in it

quartz harbor
#

does seem to be more modern than Suphi's datastore

#

yes objectively better but both are good

#

not really wasted quota much

ornate steeple
#

it also doesn't have the messagingservice event like profilestore does which, i mean, i get it because you have to go rather far out of your way to make that work and i guess suphi didn't bother to go the distance

#

since it's such a rare edge case

quartz harbor
#

@ornate steeple I figured ProfileStore doesnt use MessagingService for session locking, they use it inform other servers to process global data

#

Memory store may actually be better for session locking

#

It is good for storing temporary data

true obsidian
#

wait no i just checked and i use just UpdateAsync thats one way to create a session lock for both ReleaseLock and AcquireLock

ornate steeple
#

if you join a server while your session is still locked to a different server, the current server will listen to messaging service for the other server to unlock the data

quartz harbor
#

the session locking is in the key itself

#

¯_(ツ)_/¯

ornate steeple
#

so sure, not the session lock itself but it is related

#

it's like saying a padlock is unrelated to the key which opens it - sure, you could probably reason that. doesn't change how they are related tho

wise apex
ornate steeple
#

language do be like that

wise apex
#

Objectively, how do you store a build game without serlization?

#

How would I go about saving a building someone made without serlization?

#

So yes there are times where it is REQUIRED to serlize.

#

And if you're arguing my first message you are arguing symentics.

#

And at which point you are also incorrect, or not securing your data since the terms directly translate to converting the data to be stored to a table to save, and using that table to then be sent to them game.

ornate steeple
wise apex
#

That called sterilization.

#

Putting it into a table to store. Is called sterilization...

#

Not to mention who the message was to, was another scripter 1.

ornate steeple
# wise apex Not to mention who the message was to, was another scripter 1.

not all datatypes can be serialized, what if you wanted to store a Sound instance into datastore? s1 can make game features just not seen at effective scale. such like serialization is not relevant at s1 stage since you can just use profilestore and follow the errors and that's good enough for marketplace production code

wise apex
#

A sound instance cannot be data stored in Roblox, you would need to serialize it via taking the sound ID and storing it.

wise apex
#

Roblox datastore only accepts, text and numbers, thus a sterilization is needed.

wise apex
#

But this all goes to show, yes any datastore where you take it and turn into a table is by definition a sterilization.

#

You could datastore without them via making an array with one number, but it would still be a serialization because you pulled the number from somewhere and placed it elsewhere when you loaded it.

#

In game development code be it Roblox, Godot, unity any datastore by definition is serialized.

ornate steeple
#

this is a broad definition

ornate steeple
#

e.g if you're making a thing that saves a 3d model arrangement of vertices and related into a .mdl file, i wouldn't really describe that as serialization but seems like you would

wise apex
#

Encoding is more about changing the data to be utilized in a different form, sterilization is specific to datastoring

#

I.e if you saved a model to be used and transferred the data to be utilized in a different way, it's called encoding.

#

So to encode convert a binary, to an ascII

ornate steeple
wise apex
#

No, if you change an ascII code to binary that's encoding.

ornate steeple
wise apex
#

If you restructure a cfrme to be stored that's serialization.

#

If we're throwing json strings into the mix, it's a combination of the two

#

Step one, is sterilization of the data structure into a table

#

Step to is Jason encoding

#

Two*

#

If by some miracle you took a part and Jason encoded it, you'd be encoding.

#

Which is why the syntax is Jason.encode

ornate steeple
#

perhaps i forgot to mention that the docs mention using json as a benchmark to measure the filesize of data in the datastores, call it encoding or serialization if you will, but as a baseline the act of saving a table requires you to interact with roblox's built-in serializer; thus for simplicity and brevity it is implied and does not need to be specified.

wise apex
#

Umm, yesnt

#

These terms are terms for every language across the board.

#

It's data structure terminology

ornate steeple
wise apex
#

Not all languages are individual, and in this case specifically, data structuring has its own set of terminology. My biggest issue with Roblox development stems from this.

#

For instance frame work in Roblox is the MOST annoying term

ornate steeple
#

what about system hehe

wise apex
#

FUCK I HATE SYSTEM TO

ornate steeple
#

"ColorSystem"
the system: script.Parent.Color3=Color3.new()

wise apex
#

this is what happens when people have five minutes in programming and the only thing they ever learned was luau

ornate steeple
#

not everyone is a programmer

#

you're not an animator

#

or modeller

wise apex
#

Well, I am

ornate steeple
#

so far at least 🧐

wise apex
#

I haven't applied here cause I stopped to commission for it awhile ago

#

But I do a bit of everything

ornate steeple
#

you get the point

wise apex
#

I mean yeah, but half the people there that use these terms are scripter rolled

ornate steeple
#

follow roblox coin project like coin.touched:connect( data.gold+=1 )

#

instead of storing each field in a separate datastore datastoreservice:GetDataStore("gold"):SetAsync(player.UserId,player.leaderstats.Gold.Value) ... repeat

#

serialization is happening under the hood, but at low level it is not all that important.

#

i.e you don't need to know the ins and outs of how a car works in order to drive it

#

don't need to know how a voting system works in order to vote...

#

i digress

wise apex
#

I didn't expect them to know, that's why I linked the article for them to learn