#A lil' trouble with Suphi's DataStore Module

1 messages · Page 1 of 1 (latest)

robust stag
#

The only thing I can think of is that your data store is not empty so the template is not getting applied

#

I also see some other small problems that are not related

#

After opening the datastore can you print the value to see what's inside it

#

Try setting the value to nil then closing and starting the game again

vast cedar
#

alright i'll try 👍

vast cedar
#

alright so i tried setting the datastore value to nil once, and all that, and i got two new errors, which one is of them is the "end)" (line 19) of the playeradded function which is pretty strange and new to me since it doesn't shows the error syntax line? if you get what i mean, i also printed the datastore value and as you can see it shows nil

#

i'm completely lost

robust stag
#

Ok I see the problem

#

Your opening the datastore without the template

#

Compare line 16 in playerdata to my video

vast cedar
#

Ohh okay i see thank you so much for the help now it's working, one question, if i publish the game and i get like a few players saving data (in this case apples) in my game, and suddenly i decide to change the Apples save name to Oranges or what ever, will the data still be there? or i get to clear all data from the previous players and then create the Oranges save? if that makes sense?

#

like for example i have 30 Apples saved in data store and i want to change the name from Apples to Oranges without losing data

robust stag
#

Template only adds new data never removes data

vast cedar
#

alright i understand, besides using template can i remove data in any possible way?

robust stag
#

Yes you can save a version number inside

vast cedar
#

sorry, i'm not quite sure to understand

#

by version number you mean when you publish the game and in the game settings you see the place version number?

robust stag
#

Datastore.Value.Version = 1

#

Then you can update versions like

If datastore.Value.Version == 1 then
    datastore.Value.Apples = nil
    datastore.Value.Version = 2
end
vast cedar
#

oh okay, so setting Apples to nil clears / removes data i suppose, but once i create an other version i just have to create e.g. Oranges and other stuff and i'm done?

#

and in case i can choose to revert back from version 1?

robust stag
#

If you just want to add oranges simply add oranges to the template no need to have versions to add oranges

vast cedar
#

Okay got it, thanks for your help

vast cedar
#

A lil question, sorry for stressing you out, how would i save changes via using gui interactions? i tried creating a remote event but once i fire it, it doesn't make changes to the datastore, maybe could you provide me just a small example just so i understand? once again thanks a lot.

robust stag
#
local dataStore = DataStoreModule.find("Player", player.UserId)
if dataStore == nil then return end
if dataStore.State ~= true then return end -- make sure the session is open or the value will never get saved
dataStore.Value.Level += 1
vast cedar
#

i use this inside :OnServerEvent() right or is it just local script?