I'm making a shop system so that when you buy something an go into the main game, you get the item you got but I need to get the name of an item in a table and I'm kinda bad at scripting so pls help.
local currencyscript = require(game.ServerScriptService.CurrencyScript)
--Prices
local PotionPrice = 5000
local ShopService = {}
local DATASTORE_KEY = "Shop_01"
datastore2.Combine("DATA", DATASTORE_KEY)
--Shop
local Products = {
"Potion",
}
local BoughtProducts = {
["Potion"] = false,
}
function ShopService:Buy(product, price, player)
local ShopDataStore = datastore2(DATASTORE_KEY, player)
if currencyscript:GetMoney(player) > price then return end
for i, foundproduct in Products do
if foundproduct == product then
BoughtProducts[product] = true
currencyscript:RemoveMoney(player, price)
ShopDataStore:Set(BoughtProducts)
end
end
end
function ShopService:GetBoughtItems()
return BoughtProducts
end
return ShopService```
```local shopService = require(game.ServerScriptService.ShopScript)
game.Players.PlayerAdded:Connect(function(player)
for i, itembought in shopService:GetBoughtItems() do
if itembought == true then
for i, item in game.ServerStorage.Products:GetChildren() do
end
end
end
player.CharacterAdded:Connect(function(char)
if player.UserId == 5227384076 then
task.wait(10)
local bladeofblood = game.ServerStorage.SpecialTools["The Blade of Blood"]:Clone()
bladeofblood.Parent = player.Backpack
end
end)
end)```