What would be the most safest place to store player data? I know storing it in the player isn't safe because it can be modified client sided what would be a better alternative that's also efficient?
The best way to safely save player data
(In my experience) is using DataStoreService
. You would get DataStoreService
using:
local dss = game:GetService("DataStoreService")
Now that we have the DataStoreService, we still need to make a DataStore, by doing this we will acces or if there is no create one
local dss = game:GetService("DataStoreService") -- Getting the DataStoreService local store = dss:GetDataStore("DataStoreNameHere")
We now got our data store
It doesn't matter what you call the data store!
Now that we have accesed or created the data store, we still need to save something!
local dss = game:GetService("DataStoreService") -- Getting the DataStoreService local store = dss:GetDataStore("DataStoreNameHere") -- Getting the data store store:SetAsync("Key", "DataHere!") -- I highly suggest using the PlayerId as the key!
Now that we can save data, we still need to load it right?
local dss = game:GetService("DataStoreService") -- Getting the DataStoreService local store = dss:GetDataStore("DataStoreNameHere") -- Getting the data store local player_data = store:GetAsync("Key") or 0
Notice that i used or 0
this is if you haven't saved anything in the data store using that key, it will be nil! So if you haven't saved anything using the key, it will get 0 instead of returing nil!
The 0 can be anything! If you load it in a Value, make sure to use the right one!
For more in-depth information!
I really hope i helped you! If so, please accept this answer as i tried my best to explain this to you!
So if i misspelled some words, or if i used bad grammar somewhere in this answer. But i can explain why, it's easy, i'm not English so i make grammer errors/misspel some words
~jordikeijzers