Hello, I’ve been trying to solve this for three threads, but none of them really helped me or solved my problem.
The problem is my inventory system, I’ve been a beginner programmer for about 5 or 6 months, and even so I still haven’t managed to finish my game’s inventory system.
What I really want to achieve is an inventory system that shows the items to the player, and that can only be equipped one item at a time (that is, there will not be a hotbar, it will just be a button that will allow you to equip the item) .
What I’ve been trying to say all this time is that after three threads, I still can’t finish this inventory system, most of the time, it’s because I just can’t understand the player response code. I hope this is the last topic on this, the closest I could get to the result I wanted was with this code:
--Variables.
local ReplicatedStorage = game:GetService("ReplicatedStorage");
local PlayerService = game:GetService("Players");
--
local InventoryGUI = script.Parent.Parent
local InventoryMain = InventoryGUI.InventoryMain
local ItemsUI = InventoryMain.ItemsUI
local InventoryGrid = ItemsUI.InventoryGrid
local ItemSlot = InventoryGrid.ItemSlot
local StatusUI = InventoryMain.StatusUI
local StatusFrame = StatusUI.StatusFrame
local ItemFrame = StatusUI.ItemFrame
--
local LocalPlayer = PlayerService.LocalPlayer
local PlayerBackpack = LocalPlayer.Backpack
--
local PlayerCharacter = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local Humanoid = PlayerCharacter:WaitForChild("Humanoid")
--
--Functions.
local function GetPlayerData(Player)
for i, v in pairs(PlayerBackpack:GetChildren()) do
local ItemScriptFolder = v:WaitForChild("ScriptFolder")
local ItemStatusModule = require(ItemScriptFolder.ItemStatus)
if ItemStatusModule then
ItemSlot.ItemDamage.Text = tostring(ItemStatusModule.ItemStatus.Damage)
ItemSlot.ItemPicture.Image = ItemStatusModule.InventoryStatus.ItemPicture128
ItemSlot.ItemPicture.MouseEnter:Connect(function()
StatusFrame.ItemName.Text = tostring(ItemStatusModule.InventoryStatus.Name)
StatusFrame.ItemName.TextTransparency = 0
StatusFrame.ItemName.UIStroke.Transparency = 0
StatusFrame.ItemDescription.Text = tostring(ItemStatusModule.InventoryStatus.Description)
StatusFrame.ItemDescription.TextTransparency = 0
StatusFrame.ItemDescription.UIStroke.Transparency = 0
ItemFrame.ItemPicture.Image = ItemStatusModule.InventoryStatus.ItemPicture256
ItemFrame.ItemPicture.ImageTransparency = 0
end)
ItemSlot.ItemPicture.MouseLeave:Connect(function()
StatusFrame.ItemName.TextTransparency = 1
StatusFrame.ItemName.UIStroke.Transparency = 1
StatusFrame.ItemDescription.TextTransparency = 1
StatusFrame.ItemDescription.UIStroke.Transparency = 1
ItemFrame.ItemPicture.Image = "rbxassetid://"
ItemFrame.ItemPicture.ImageTransparency = 1
end)
else
return
end
end
end
GetPlayerData()
PlayerBackpack.ChildAdded:Connect(function(ItemAdded)
local SlotClone = ItemSlot:Clone()
SlotClone.Parent = InventoryGrid
local ItemScriptFolder = ItemAdded:WaitForChild("ScriptFolder")
local ItemStatusModule = require(ItemScriptFolder.ItemStatus)
if ItemStatusModule then
SlotClone.ItemDamage.Text = tostring(ItemStatusModule.ItemStatus.Damage)
SlotClone.ItemPicture.Image = ItemStatusModule.InventoryStatus.ItemPicture128
SlotClone.ItemPicture.MouseEnter:Connect(function()
StatusFrame.ItemName.Text = tostring(ItemStatusModule.InventoryStatus.Name)
StatusFrame.ItemName.TextTransparency = 0
StatusFrame.ItemName.UIStroke.Transparency = 0
StatusFrame.ItemDescription.Text = tostring(ItemStatusModule.InventoryStatus.Description)
StatusFrame.ItemDescription.TextTransparency = 0
StatusFrame.ItemDescription.UIStroke.Transparency = 0
ItemFrame.ItemPicture.Image = ItemStatusModule.InventoryStatus.ItemPicture256
ItemFrame.ItemPicture.ImageTransparency = 0
end)
SlotClone.ItemPicture.MouseLeave:Connect(function()
StatusFrame.ItemName.TextTransparency = 1
StatusFrame.ItemName.UIStroke.Transparency = 1
StatusFrame.ItemDescription.TextTransparency = 1
StatusFrame.ItemDescription.UIStroke.Transparency = 1
ItemFrame.ItemPicture.Image = "rbxassetid://"
ItemFrame.ItemPicture.ImageTransparency = 1
end)
end
end)
--
(Also, the GUI Parents & Childrens).
Yes, it’s a pretty crappy way to do the inventory system, but it’s all I could do. Thanks.