Now obviously you can’t perform arithmetic on strings I know my error, but I was wondering what the alternative would be given I know how to do it manually but this needs to be done automatically.
–Services
local ReplicatedStorage = game:GetService(“ReplicatedStorage”)
local ServerStorage = game:GetService(“ServerStorage”)
–Modules
local DataStore2 = require(ServerStorage:WaitForChild(“DataStore2”))
–Locals
–Bind to clickDetector.MouseClick
script.Parent.MouseClick:Connect(function(player)
–Localize fruitName, destroy fruit (debounce)
local itemName = script.Parent.Parent.ItemName.Value
script.Parent.Parent:Destroy()
--Get inventoryStore, updateInventoryStore
local inventoryStore = DataStore2("Inventory2", player)
inventoryStore:Update(function(currentTable)
currentTable["Inventory"] = currentTable["Inventory"] + itemName -- temName is the object added to the inventory.
--MUST return updated table
return currentTable
end)
end)
