I cant figure out how to detect which slot the item that you picked up must go in.
I have tried checking if the slot is full but that hasn’t worked.
Code:
local Class = require(game.ReplicatedStorage.Classic)
local ServerStorage = game.ServerStorage
local Point = Class:extend()
local Items = {
["Apple"] = script.Items:WaitForChild("Apple");
["Fish"] = script.Items:WaitForChild("Fish");
["Hotdog"] = script.Items:WaitForChild("Hotdog");
}
function Point:new(Slots)
self.Slots = Slots or 1
self.UsedSlots = 0
self.Item = nil
end
function Point:AddItem(Item)
if self.UsedSlots + 1 > self.Slots then return end
if Item == self.Item or self.Item == nil then
self.Item = Item
self.UsedSlots = self.UsedSlots + 1
end
end
function Point:GetSlotData()
local Data = {
Slots = self.Slots;
UsedSlots = self.UsedSlots;
Item = self.Item;
}
return Data
end
function Point:DropItem(Position)
if self.Item then
if self.UsedSlots - 1 ~= -1 then
local ItemClone = Items[self.Item]:Clone()
ItemClone.Parent = workspace
ItemClone.Position = Position
local PickUpScript = script.PickUpScript:Clone()
PickUpScript.Parent = ItemClone
self.UsedSlots = self.UsedSlots - 1
if self.UsedSlots == 0 then
self.Item = nil
end
end
end
end
function Point:CanAdd(Item)
--Check if the slot is has the same item or if it is empty.
end
return Point