Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

I want to make a proper weapon save but can't think of any solutions ?

So, I am making a game with a weaponry system and a key part of the concept is the ability to save Tools WITH ammunition, Ammunition being a NumberValue that is stored in the gun.

I've been struggling to find any solid answers for this exact problem for about 1-2 days, and still have no idea of how to realise this. Hope posting here will give any help.

2 comments

0

Use datastores, save tools/values by its names and accoding values

0

I'll try that, lets see.

1 answer

✓ Accepted answer

You will need to serialize the data that you're saving.

Essentially, since you can't save an Instance or a table, you can make it look something like this instead:

DataStore:SetAsync(player, "Rifle/15") -- Let's say the 15 represents the amount of ammo they have when saving.

In this example, you can use string.split to separate them by the / - so this gives you an array containing "Rifle" and "15". From there you can use these to give the player a Rifle and set it's ammo to 15.

A more in-depth tutorial on serialization can be found here: https://devforum.roblox.com/t/how-to-save-parts-and-the-idea-of-serialization/524311

2 comments

0

You actually can save tables now, it converts into a kind of string code and when you use GetAsync its converted back into a table.

0

Big thanks !

This discussion is preserved as it was. New answers, comments, and votes are closed.