Weapon/Item Saving

When making a weapon, or item save to a datastore how would I go about saving a weapon/item to a key the most simple way possible. I’m a rookie when it comes to datastore, and I’m not that advanced at coding yet.

2 Likes

As long as you’re not saving a ridiculously large amount of weapons, you can probably just save a table containing the names of the player’s weapons. It doesn’t need to be super complex.

--assume variable "weapons" is a table containing the player's tools
local tableToSave={}
for i,v in pairs(weapons) do
    table.insert(tableToSave,v.Name)
end
--then use DataStoreService or some other solution to save the table

I’ve tried saving a table to the key but it wouldn’t work for me. I think it’s because the key itself is a table.

Firstly, make sure you have all the tools in a Folder preferably in ServerStorage.

On PlayerRemoving you should for loop through the player’s Backpack and insert the tool names into an array which you’ll save.

On PlayerAdded loop through that table, find the name of the tool in that Folder, clone it and parent it to the player’s Backpack.

2 Likes

that sounds very simple I think I’ll give that a try, thanks!

1 Like