Suphi's DataStore Module

and the error is still showing up too

The value you set needs to be a string type

Hey Suphi! I love your module, been using it for quite sometime, I was wondering if thereā€™s a way I can determine if a player has joined for the first time and has no data, I need it in order to modify the base template when opening the session without making it yield if data has already been found, Thanks!

PD: I tried using the CreatedTime property of the dataStore but it isnā€™t really an efficent method for what iā€™m trying to achieve

Yeah, nvm, the solution was really simple, just had to look if the dataStore had any value :woozy_face:

2 Likes

Yup or inside the template add a counter that starts at 0 and every time the state turns true add 1

2 Likes

Yeah I was also considering that! however, I came out with a better solution for my case

What if when opening a session it also returns the first data value before reconciling it / using the template?

Just an idea Iā€™d like to see if you update the module anytime soon, thanks for everything :saluting_face:

it is and the error is still showing up

Canā€™t you just, not reconcile it then? You have to call :Reconcile(template) yourself soā€¦ just dont

Can you place this above the error

 print(type(dataStore.Value[name]))

And tell me what it prints

If you have multiple player added events then you will run into the problem of not knowing the order of these events and thatā€™s why its always best to reconcile during the open that way it does not matter what player added runs first the datastore will always be ready after the open function ends

2 Likes

I do have a so called game. Dm me.

it just says string https://gyazo.com/cd1baf86de1c67bb3338878e7fda6469

The error is before it prints string so that means the error is coming from another location

https://gyazo.com/0ae5b70eba91e849afec251e60d018a5

did you print the type before setting the value or after?

I think it did it before after

game.Players.PlayerAdded:Connect(function(player)
	task.spawn(function()
		local dataStore = DataStoreModule.new("PlayerData", player.UserId)
		dataStore.StateChanged:Connect(stateChanged)
		stateChanged(dataStore.State, dataStore)
	end)
	task.spawn(function()
		local dataStore = DataStoreModule.new("PlayerData", player.UserId.."-Plot1")
	end)
end)

In the script where I use local dataStore = DSM.find("PlayerData", player.UserId.."-Plot1") it seems like it canā€™t find they key, why not? The player.UserId key works

Are you using it in playeradded?

Iā€™m using the .find() in another script in PlayerRemoving.

the only 3 ways find would not work is if

  1. you destroyed it somewhere else
  2. bindtoclose ran first and destroyed it before PlayerRemoving was fired
  3. you never called new()