My Data Store script doesn't work

Did you enable API service? In Game Settings in studio > Security> Enable Studio Access to API

1 Like

The “end of the code” appears, so I noticed now, it appears that the data are saved but are not loaded but I activated the studio api

But how do you increase or decrease your currency
Maybe some way you change your currency will destroy the script

1 Like

Do you create the player.DataStore.Coin1 and the other variable BEFORE loading? maybe the script tries to load into these variables before they are even created, try inserting the script that creates these folders and values into this script, here is a tutorial on doing DataStores: https://www.youtube.com/watch?v=DkYupSBUpes

1 Like

My script was almost identical to the one in the video and it worked well with 1 value but I couldn’t make it work for 2 values.

But have you tried to make a script which is for Coin1 and make another scrript which is for Coin2
I just asking but idk will it work

1 Like

I know how to do that and I know it works just that I wanted to save space and learn new things.

Man, forget about current DataStore and go straight to DataStore2

DataStore2 is a bit complicated. Also it doesnt save much space actually

I’ve heard of it and I know the differences between normal but if there really isn’t any way to solve this, I have to choose this option.

Could you try changing

player.DataStore.Coin1.Value = data.Coin1
player.DataStore.Coins2.Value = data.Coin2

to

local DSFolder = player:WaitForChild("DataStore")
DSFolder:WaitForChild("Coin1").Value = data.Coin1
DSFolder:WaitForChild("Coins2").Value = data.Coin2

Quite the contrary! I almost went crazy trying to make the native DataStore work and now with DataStore2 I have everything working … The code is clean, reduced and mainly the rescue system is reliable. Just looking at which bestseller games currently using Datastore2, it’s no wonder …

ok,im sorry about that, how about you briefly explain how it works and we can learn?

1 Like

Very easy to learn, just read the examples there: DataStore2

1 Like

I think it’s better to choose DataStore 2, I just know that this is going to be very complex but it’s life. Nothing seems to work in this script

Btw @rogeriodec_games Do you know about ContextActionService?

1 Like

Have you tried this?

Do that at the PlayerAdded section

yes just that it still doesn’t work

Your help was still worth it. Thanks.

1 Like

It was difficult to understand at first but now everything works as I want.