Datastores not saving

Hello,
I got some data store scripts here that arent saving and im not sure why and there was also no errors

Script One:
local datastore = game:GetService(“DataStoreService”)

local ValueStore = datastore:GetDataStore("TTB")

local value = game.ReplicatedStorage.TTB

game:BindToClose(function()

ValueStore:SetAsync(game.ReplicatedStorage, value.Value)

end)

Script Two:
local datastore = game:GetService(“DataStoreService”)

local ValueStore = datastore:GetDataStore("TTB")

local value = game.ReplicatedStorage:WaitForChild("TTB")

local THEVALUE = ValueStore:GetAsync(game.ReplicatedStorage)

value.Value = THEVALUE
1 Like

The key, first argument of SetAsync and GetAsync expect a string, you’re giving an instance

but the TTB in rs is a string value

I am not referring to the StringValue, you’re giving the first argument of SetAsync and GetAsync game.ReplicatedStorage, ReplicatedStorage is an instance, it expects a string to be given to be the key

Oh, So how might I fix that???

You give it a string to act as the key to reference…

If you want the key to contain the value of the StringValue to be bob, then change game.ReplicatedStorage to "bob" for SetAsync and GetAsync

Oh ok, Thank you ill try it out

I tested it, but it didn’t load/save the value

Are you changing the value from the client or the server?

I dont know what u mean but its a value in the rs and im just clicking on it in game and changing it, sorry

That sounds like you’re changing it from the client then, go to the test category on the top of your screen and click on Current: Client to change to the server’s perspective, then change the value.

okay ill go try that, thank you

It worked!, Thank you so much!!, also just 1 more thing you could help me with, how will make a value in the player that saves but doesnt show on the leaderboard

Just parent the value somewhere else outside of the leaderstats instance, the value only shows up on the leaderboard if it’s in an instance in the player called leaderstats

1 Like

ohhhh, alright, thanks for your help!

1 Like