You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Make a super custom inventory! - What is the issue? Include screenshots / videos if possible!
I have 2 problems that may be super simple to solve but I don’t realize
This is how the inventory gui it’s looks
The biggest problem is that when I drop an item or equip it, the slot it belongs to is still in use for some reason but when I grab a new item the slot is updated with the information of the new item but I don’t want that exactly and I can’t find a way to make the slot empty if there is no item in the inventory folder, I already tried several things but ended up discarding them, such as conditions etc, but without result.
The small problem what i imagine is super easy to resolve is that the items when equipping or throwing them stop working
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local Inventory = Player:WaitForChild("Inventory")
local Manager = script.Parent:WaitForChild("Manager")
local Gui = script.Parent
local Frame = Gui.Manager.ScrollingFrame
local Slots = Frame:GetChildren()
local Sound = Player.PlayerGui:WaitForChild("InventoryOpen")
Mouse.KeyDown:Connect(function(Key)
if Key == "b" then
Manager.Visible = not Manager.Visible
Sound:Play()
end
end)
local function Clear()
for _,v in pairs(Slots) do
if v:IsA("TextButton") then
v.AutoButtonColor = false
v.Text = ""
end
end
end
local function Drop(Object)
for _,v in pairs(Slots) do --i made a big mistake here, and i dont know how to figure how to drop only the selected item
if v:IsA("TextButton") then
local Tool = Inventory:WaitForChild(v.Text)
Tool.Parent = game.Workspace
Tool.Handle.CFrame = Player.Character.HumanoidRootPart.CFrame * CFrame.new(0,0,4.5) --items drops near of player but they can't be picked up again, why?
v:ClearAllChildren()
end
end
end
local function Grab(Object)
for _,v in pairs(Slots) do
if v:IsA("TextButton") then
local Tool = Inventory:WaitForChild(v.Text)
Tool.Parent = Player.Backpack --It works fine but the tools don't work, as well as how to pick them up --Sorry my bad english
v:ClearAllChildren()
end
end
end
local function Cancel()
for _,v in pairs(Slots) do
if v:IsA("TextButton") then
v:ClearAllChildren()
end
end
end
local function GetOptions(Object)
local Options = {}
table.insert(Options, {
"Grab",
function()
Grab(Object)
end,
})
table.insert(Options, {
"Drop",
function()
Drop(Object)
end,
})
table.insert(Options, {
"Cancel",
function()
Cancel()
end,
})
return Options
end
local function ShowOptions(Slot, Object)
local Options = GetOptions(Object)
for i = 1, #Options do
local Button = Instance.new("TextButton")
Button.Size = UDim2.new(1, 0, 1/#Options, 0)
Button.Position = UDim2.new(0,0,i/#Options - 1/#Options, 0)
Button.Text = Options[i][1]
Button.MouseButton1Click:Connect(Options[i][2])
Button.Parent = Slot
end
end
local function Update()
local InventoryTab = Inventory:GetChildren()
for i = 1, #InventoryTab do
Slots[i].Text = InventoryTab[i].Name
Slots[i].AutoButtonColor = true
--here the problem is what inventory no detect when there's no tool in inventory folder and the slot is still in use
Slots[i].MouseButton1Down:Connect(function()
Cancel()
ShowOptions(Slots[i], InventoryTab[i])
end)
end
end
Manager:GetPropertyChangedSignal("Visible"):Connect(function()
Update()
end)
I hope someone help me resolving this T-T
CustomInventory.rbxl (68,8 KB)