#Suphi's DataStore Module
1 messages · Page 2 of 1
is there any way to close the session using that id
I recreated it just now
yes you just delete the memory store
nice
I don't know what that warning is
It closed the normal and time datastore
looks like your trying to access the datastore without checking its state
it's an internal warning iirc
well I don't think so
getTimeDatastore should yield until the session is open
but these errors are not related to are problem
one second
can you try something
im trying something rn
well can you try this idea I have
once you enter the game
open the data store like you normally do
then after like let's say 10-20 destroy the datastore
but stay in the game don't exit
and see of the data store reopens
put a print so you know the data store is trying to open again
this returns 2 different uuids?
also you don't need to deep copy template SDM does that for you
oh Alright
you have 2 datastores
really you should just have 1 per player
but that shoes that its failing for both
can you try the thing I said
in wondering if something is reopening the data stores after its been destroyed
should i do it ingame
@covert crescent
was it the statechaned that opened my data again?
it couldn't be
right?
I don't know how you did it
did what
what is this showing
is the server opening the session again after you destroy it
the first 10 or so messages are there because my data session previously failed to close when I was migrating to latest update
ignore them
yes look at the last 5 lines
let me do it again more clearly
here
the first 3 are from when I join the server
why does it say locked?
look at the timestamps
after I close the datastore it immediately tried to open it again
ok
sooo what I think is happening is not that we need the task.wait in bind to close
is when you teleport a player it instantly trys to reopen
there data store and then locks them out
wait I forgot to disable my timestep function that gets called every second
lemme disable it and retry
ok
but still
even without the time step
you should only be opening the data store if the player enters the server or there data store is closed not destroyed
You're right
so let's look at your code where when the state changes it opens the datastore again
I think I found the issue
the timestep called every second so if it gets called after BindToClose gets fired then the function would reopen the datastore
hence locking the session
but your code should not even try to open the session if the data store does not exist
only when the player enters or if the state becomes closed
but never if the state is destroyed or it can't find the data store
but I think that my bindtoclose function should protect you from opening the session after it tries to close but I can't remember
this should hopefully fix it?
the false tells the function not to open the datastore if it couldn't find it using datastore.find
yes
I think that is supposed to stop you from opening new datastores
after bindtoclose fires?
but maybe its not 100% safe
maybe if you start opening just before active is set to false it might bypass it
butt
if you do what I said
then you don't even need active
I do that though
so the rules are
1 only open the datastore if the player entered the game
2 only open the datastore if the state is closed
I open the datastore on playerjoin and then use .find whenever i need to access the datastore
it broke again even after I added a failsafe to timestep
looks like your still opening it after you destroy it when you should not be doing that
let me check which part of the code does that
if you do find and don't find it then you don't open it
if you open it after find that's not correct
ds = find(...)
if ds == nil then new() end
doing this is wrong
i'm doing
you should only call new inside player added no where else
also show me your state changed function maybe there is a problem there
also maybe when you do migrate update it does not call bind to close instantly ?
anyways let's see the state changed function that reopens your data store
Alright so the issue is fixed
For anyone having the same issue where the session does not get closed after you migrate to latest update or shutdown all servers, Check your scripts and see if anything opens the datastore again after player leaves it could be anything like a cash loop or a time loop that increments the player's time played every second
@covert crescent you should check the active thing again since it was letting me open the datastore even after bindtoclose had already fired
and always follow this
yer what i think happens is
when you migrate the server does not shut down instantly it teleports players slowly so the active thing does not get triggered while migrating
and only once the last player gets teleported then active becomes triggered
but its good the know there is not a fundamental problem with SDM but we must be careful not to open a datastore outside of a player entering the server
Yup
as long as you follow the rule
only call datastore.new inside player added and no where else then you should always be ok
Yeah that's what fixed my problem
outside of playeradded you can only use datastore.find
I tested > 50 times with shutdown all servers and migrate to latest update with 5 people and the bug did not occur again
yeah
i might post it on the forum
thanks for the help though
:D
@covert crescent how would i make a leaderboard with this since i cant do getorderdereddata
there is a leaderboard example at the top
yup
tysm
are the datastores accessible across the experience or place level only?
each experience gets its own datastore that all places attached to that experience can access via standard luau apis
but you can access the experiences datastore from outside the experience via robloxs cloud apis
does the module still work fine even with the recent changes to datastores?
yes - but what are the changes even
such as the experience wide datastore API limits (instead of server wide)
oh yer that's fine SDM does not use that many API calls
does this module have safety features to ensure that players do not get locked out of their data for a week if MemoryStoreService goes down like it did today?
datastores is locked for 5 minutes so a player will have to wait at most 5 minutes if there is a failure
how do i wait for dataStore.Value to exist without stopping the entire function? do I use pcalls or repeat until true
-# this is my first time using this module and im new to scripting btw
local RESPAWN_DELAY = 3
local function onPlayerAdded(player)
local function onCharacterAdded(character)
local humanoid = character:WaitForChild("Humanoid")
local function onDied()
task.wait(RESPAWN_DELAY)
player:LoadCharacterAsync()
end
humanoid.Died:Connect(onDied)
end
player.CharacterAdded:Connect(onCharacterAdded)
player:LoadCharacterAsync()
-- i want player to spawn at dataStore.Value.Stage but dataStore.Value ends up being nil
end
Players.PlayerAdded:Connect(onPlayerAdded)
You'd connect to datastore's StateChanged event
Would I do find(), new() or open()?
new
What does dataStore:Set() do in the Signal example?
Also does ValueChanged fire for every data that changes in datastore? for example if I have Coins and Playtime, does it fire every time either one changes
Ohh nevermind I guess it's a custom set function that fires signal while also changing the value
and that also answers my other question
How can I manually destroy the datastore everytime PlayerRemoving is called?
Ds.Value = nil
This automatically compresses dictionaries right?
Attempting to load data with this template but I am getting a "Cannot Store Dictionary error"
I couldve sword it formatted data like this
Might be unsupported types in Color3 lemme check
Yeah Im like 90% sure this is the reason
Nvm then
Anyway if anyone knows the supported way for me to get the CompressedValue, please let me know.
I assume its wrote-to after the DataStore is closed or saved
You can't save colors you have to convert them to hex
This is no where near the limit you dont need to compress
Yeah gotcha, found that out earlier
found your video covering compression, I plan on working on a game with larger data requirements which I am gonna possibly need compression
99% of games dont need compression
Also if you compress you will be locked into SDM V1
It will be difficult to move to another module
rip 😢
I guess you're right
Will SDMV2 support Color3,Vector3 and other luau datatypes?
No SDM does not modify data by default unless you compress
So only what roblox supports is supported
Doesnt it Compress here?
Maybe I'm misinterpreting it
Thats the function but its disabled by default it also does not support colors
Neat
Am I using the "find" function worng here? I supposed the third argument was to find a specific key inside the datastore, issue is this return nils, even tho the key I am trying to search for is correctly stored inside the player data store
oh wait yes, i remember, it's only to find datastore not key inside it
my bad