I am trying to make a character customization that you can only use once and it saves, however I have no idea on how to make the character save when it leaves or resets character. Pls help :)
datastores are thing that saves to roblox api service, used for saving datas like player left and rejoin and have the same thing the first thing you should do is set up a data store, its simple: (actually you dont need to set up, you can just index it or lazy make a variable about it, i didnt because i am also lazy)
local MyDataStore = game:GetService("DataStoreService"):GetDataStore("myDataStore")
to save datastores, use :SetAsync or :UpdateAsync, and the arguments (like what you should put) are keys, (keys must be specific between each user) and value you want to save, heres an example
game:GetService("DataStoreService"):GetDataStore("myDataStore"):UpdateAsync("Key".. player.UserId, 100) -- UPDATES to 100 value with the given key
what about, getting the data??? you shouldnt just save the data and leave it alone, its like wasting time, to get the data use :GetAsync() and the arguments are keys, no value needed because you are getting it
heres some example
game:GetService("DataStoreService"):GetDataStore("myDataStore"):UpdateAsync("Key".. player.UserId, 100) -- UPDATES to 100 value with the given key game:GetService("DataStoreService"):GetDataStore("myDataStore"):GetAsync("Key".. player.UserId") -- 100 wowoowowowowo except you got an error because timeout
hey, forgot to mention this, but data store might NOT SAVE 100% all the time, its because api service being noob, so thats why you should use UpdateAsync, so values still save from last play
heres some way to prevent:
use a code to detect error, if it gets error save it again and if it gets error again then just ignore it lol
save the data like every minute, dont save it like 1 second, about some detailed explaination then click here, if you are terrified with hyperlink then copy this https://developer.roblox.com/en-us/articles/Datastore-Errors
no idea now
and last thing, very important, dont use UpdateAsync like super often like every 1 second because api service is gonna die if you set it too often (not actually die, i dont have anything else to say), but just like save it every 30 seconds, and save it once if player left, or twice
bye