I’m making an RPG game on Roblox, and I recently modeled the first piece of equipment for it, just a simple pair of leather gloves. Here’s the thing though, I want every piece of equipment in this game to have a unique set of stats, decided by rarity and such, like so:
In this image, a folder of stats is present. There are two folders in it named CommonBuff, and a NumberValue named MaxHealth. MaxHealth is 5, as the gloves will give 5 health by default. I’ll worry about rarities later, I just want to get started. How can I make it so CommonBuff turns into a completely randomized NumberValue (Health, Damage Res, etc.) every time the tool Leather Gloves is given to a player?
AND, how can I make it so these stats retain after it’s been equipped (and in DataStore?)
Store the randomized stats as attributes or ObjectValues on the tool itself when it’s first generated, not in folders. Makes it way easier to save to DataStore.
When you give the player the tool, check if it already has stats. If not, generate them once and save. If it does, use the existing ones.
For DataStore, serialize the stats into a table like {MaxHealth = 5, Damage = 10} and save that with the tool data. When loading, reconstruct the stats from the table.
Don’t regenerate stats every equip or you’ll lose the unique values. Generate once, save, then reference those saved values.
For the randomization itself, just pick random stat types from a pool and assign random values based on rarity when the tool is first created.
Gotchu. This answer is exactly what I was looking for, I just wanted a set of instructions to work off of, not a script. Thank you, I’ll work toward it and I’ll report back once I’ve gotten a simple base set up.