Hello, I need some pointers as to making a shopping system like Lumber Tycoon 2. I saw one post that had something like it but it was very messy and I didn’t gather much so I decided to make my own.
I need help with detecting when an item is placed on the counter and when it is taken off. I am using touched events and tables at the moment and I want to know if theres a better way to do this.
local CollectionService = game:GetService("CollectionService")
local store = script.Parent
local storeItems = store.StoreItems
local shopkeeper = store.Shopkeeper
local counter = store.Counter
local counterTop = counter.CounterTop
local itemsOnCounter = {}
counterTop.Touched:Connect(function(hit)
if CollectionService:HasTag(hit.Parent, "ShopItem") then
table.insert(itemsOnCounter, hit.Parent)
print("An item has been put on the counter")
end
end)
Is this any good? Thanks!