So I’m trynna make an inventory system wich stores all the values (in-game resources) and you can see them by accesing the inventoryGui.
The script works and clones the Frames to the InventoryGui when the player spawns for the first time, but once you die or respawn the cloned Frames on the Inventory are Deleted.
I also asked some people and they told me to use Player.CharacterAdded, and I tried but failed since I dont really know how to use it.
I have used the Player.CharacterAdded before, but on a character customization system and I think its a litle different since I’m cloning Hair and Faces there and not a Frame for a Gui.
--
Also if someone wants to know a little more how the inventory works and how the Frame clones get deleted when you die or respawn here’s the link to my testing place. https://www.roblox.com/games/9370713652/Tool-Testing
Well, I tried it and it kinda works. I tried printing someting and it worked, but it doesnt really work with the functions, do you know if there’s anything wrong with them?
I will leave the first function in case you can help me with this. Thanks tho
--So this is the first function that clones the Frames for the Inv.
--The thing works when the player joins the game, but not when the player respawns.
local function SetupInv(plr)
local Inv = plr:WaitForChild("Inventory")
local plrGUI = plr:WaitForChild("PlayerGui")
local MainGUI = plrGUI:WaitForChild("InventoryGui")
local MidFrame = MainGUI:WaitForChild("MiddleFrame")
local InvScrollingFrame = MidFrame:WaitForChild("ScrollingFrame")
for i, item in pairs(Inv:GetChildren()) do
local templateFolder = RS:WaitForChild("itemFrameTemplate")
local itemGUI = templateFolder:WaitForChild("itemFrame"):Clone()
itemGUI.Name = item.Name
itemGUI.itemN.Text = item.Name
itemGUI.itemQ.Text = item.Value
if item.Value > 0 then
itemGUI.Visible = true
itemGUI.Parent = InvScrollingFrame.ItemList
else
itemGUI.Visible = false
itemGUI.Parent = InvScrollingFrame.ItemList
end
end
end