I have a script which someone helped me make (thank you Von 🙏) which loads a set of values into the player upon joining, i havent done datastores before and before i move onto giving it a go, im wondering if i can data store values that get added to the player, rather than values that are already on the player, it might be a dumb straightforward question to someone who a shred of experience on datastores but i’d like an answer before i move forward
#Question about datastores
1 messages · Page 1 of 1 (latest)
game:GetService("DataStoreService")
you get data you store em in the server for later
this works even offline btw
that how games keep your money saved up
attach the data to the player id
when game is loaded load the data and apply it to a gui or anything like that
So even if the values are loaded into the player upon joining it can still be datastored?
yes
Thank you 🙏
wait do you mean values givin to the player after they join? yes, any value can be stored into datastores. you'll just have to confirm they have valid data before loading it.
say we have a player state givin right when they leave, say our player is givin the state of "phasefour", we can save that right before they leave then load it when they join.
Yes using the roblox escape key thingy
And maybe this is a stupid question, dont feel obligated to answer but how do i check if theres valid data?
You dont
Input service?
You just gamble your luck
Yea id rather use that but idk how it works
well it depends
in this case i mean valid data as in everything but NIL
-# nil is essentially nothing
we can just check the players data and confirm its NOT nil
Remember nan is different than nil
if playerdata ~= nil then
--load your data
end
^
So im good to go and i can just load the data and as long as i load it after the values are in the player its fine?
** You are now Level 1! **
Fuck off mee6
use nan for numbers nil for objects
Why cant i use nil?
local DSS = game:GetService("DataStoreService")
local Datastore = DSS:GetDataStore("MyStore")
game.Players.PlayerAdded:Connect(function(p)
local Key = p.UserId
local PlayerData = Datastore:GetAsync(Key)
if PlayerData ~= nil then
-- Data exists!
print(PlayerData)
else
-- Data doesnt exist
warn("NO DATA FOUND!")
end
end)
game.Players.PlayerRemoving:Connect(function(p)
local Key = p.UserId
Datastore:SetAsync(Key, 10)
end)
here is a basic example of a datastore
Right right
Thank you for this
I will be checking out coral game
This also works for connection purposes
well in some cases you could.
Remember he said IN SOME CASES
nil again essentially is nothing so in certain cases you could use it
such as throwing an object away from workspace but keeping it in memory
mypart.parent = nil
you can still access "mypart" but it wont be in the workspace
I suggest storing it in replicated storage tho
depends, if its a sensitive script it would be preferred to store it in serverstorage, replicatedstorage is seen by the client so exploiters have access to everything in it.
Storing the value in replicated?
Yes i suggest using serverstorage for values and replicated storage for models
good question, it depends on the game & model.
if you have say a building game you would want to save a table with parts and plot positions in datastore
then load the plot
Those are loaded locally so no need
I would racomend that static objcet are loaded in locally
And that models that change overtime be stored in data
** You are now Level 5! **
Im saving this for later cuz its important
? wait i dont get it, please elaborate 👀
** You are now Level 2! **
In grow a garden
Your place changes overtime
i dont play gag, do you mean model loading when a player joins?
** You are now Level 9! **
OH I GOT IT
Your almost there
so plant growing! gotcha!
goodbye!
You helped us 😭
anyways, feel free to post further questions here., ill check out other threads.