Hey guys! I’ve been working on this shooter game, and I decided to add a character shop, where you can customize the StarterCharacter the game gives you by using “bucks” which is an ingame currency. I have created the shop, that contains all of the buttons to buy these characters, but how would I get this to save across games?
Does anyone have guidance on how to do this? You don’t really have to spoon-feed me code, but I’m very confused as to what to do here and how I would save the other character across playing sessions, AND the bucks, so atleast some general tips or guidance would be nice! I already have the system for creating the bucks and giving them to players (it is located in a folder in ReplicatedStorage called Players, and the name is [Player Username]bucks. I.e. Y35Xbucks.
I know the whole player changing part, where they actually equip it. My main concern is more on leaving and re-entering the game, keeping the settings, ensuring that their bucks amount is the same, and also the items they own.
Data cannot be saved across games without using an external service. You can save data across places in a game though using DataStoreService though. Ideally you would be saving identifiers. Any code work, other than processing the character’s world appearance, would be handled through these pieces of data.
So would the best idea be to store values of whether or not each item is owned (with a bool value probably) and also another value of which one they have equipped?
Sure. You might not want to save raw names though since that’ll eat up the character limit you have for a DataStore key (260K characters) and instead opt for condensing your data by using numbers or other ids instead, but if you don’t have that many items then feel free to use raw names as well. Same goes with the Equipped table.
yes you can save bools strings but not objects i would recommend making a new string value of the item and then put it inside the players data folder and load the shirt based on the string values name
My plan was to simply save it as “Char1”, “Char2”, “Hat1”, “Hat2”, all as names of bool values, all representing items and their shop number, with true and false being whether or not they own it. From there I would also add “HatEq”, “CharEq”, etc. for what they have equipped, these would be number values, with the number correlating to the item number. Is this condensed enough to fit the limit?
I am referring to gaming sessions. Although, within the same game there are 2 different places. There is a singleplayer place, and a multiplayer place. Would this be an issue to transfer over from the data storage?
No, DataStores will be accessible from every place inside your game.
and you could condense your info to a bit string with each digit corresponding to a specific item in catalog (1 for yes, owned. 0 for no)
You can hardcode the relationship and asset id’s, all you need is if the player owns it saved.
Unless your catalog is so large that a bit per item is larger than your average players collection
You can learn how to use DataStore to saving items in table, create a folder in the player name “EquippedChar” , also when player join a game, there will be a script that check their equipped character and then module their, else if player not have any equipped char, then it will module and give them an default character. Here is the best choice for you if you want to learn how to saving items in table!
Yeah. I was going to add a playerAdded, and then in there a characterAdded, and detect what they have saved. Would there be a way to detect what they have equipped though? I have toros colors, materials, hats, and heads, so I’m assuming I would just add 4 digits to the end and the number would be the “ID” of the item within the game?
Thanks! And I will check out the link. One thing though, can’t the player configure values and items that are within the player? If so, then this would allow exploiters free-range to equip any item they please.
Equipped items you would want references to the actual item. perhaps a number (5) which is a specific hat (whose ownership is the fifth digit)
Each equipped item would have its own saved variable, but the set would never exceed the size of max # of items one is able to equip.
so:
ownershipBits = “…”
hat = 5
character = 19
socks = 190
leftEarring = 201942 ?
–hehe
Oh okay, I see! Is there a way to check specific digits within a string? For instance, the game is checking if you own “Domino Crown”, and Domino Crown’s digit within the string will be 4. So how would you configure the digit upon leave to show that domino crown is bought, and then upon rejoin check the digit to see if it is owned?