I'm trying to figure out the best way to save the swords a player owns. My current way is just a number for each sword but I realized this won't work for more swords. I was thinking of making a data save for every sword and making it 1 for owning and 0 for not but I thought there might be a better way.
Heres what I currently have:
game.ReplicatedStorage.Purchase.OnServerEvent:Connect(function(Player, Sword)
if Sword == "Bronze Sword" and Player.leaderstats.Points.Value >= 25 and Player.EquipedSword.Value ~= 2 and Player.EquipedSword.Value ~= 23 then
Player.leaderstats.Points.Value = Player.leaderstats.Points.Value - 25
Player.PlayerGui.SwordShop.Frame.Bronze.Text = "[OWNED] Bronze Sword"
if Player.EquipedSword.Value == 3 then
Player.EquipedSword.Value = 23
else
Player.EquipedSword.Value = 2
end
elseif Sword == "Iron Sword" and Player.leaderstats.Points.Value >= 50 and Player.EquipedSword.Value ~= 3 and Player.EquipedSword.Value ~= 23 then
Player.leaderstats.Points.Value = Player.leaderstats.Points.Value - 50
Player.PlayerGui.SwordShop.Frame.Iron.Text = "[OWNED] Iron Sword"
if Player.EquipedSword.Value == 2 then
Player.EquipedSword.Value = 23
else
Player.EquipedSword.Value = 3
end
end
end)
Thanks in advance.

5 comments
btw I'm supposed to be doing Geography rn lol
I just save a table of all the items a player owns(all the names). All the weapon information is static data that is in a module and not saved.(yes I know that is what sweet said)...
Any chance you could show me an example of the DataStore list?
Note: Datastores aren't tables, I'm just using it to represent a datastore.. DataStore: { id_123 = { OwnedItems = {"WOODEN_SWORD", "DIAMOND_SWORD"} }, id_456 = { OwnedItems = {"WOODEN_SWORD"} } }
and "WOODEN_SWORD" and "DIAMOND_SWORD" would be Item IDs, stored in a ModuleScript.