[Half Solved] New panels are not generating correctly on my inventory system, what's the problem?
Asked by
6 years ago Edited 6 years ago
So I've made a massive inventory system that works similar to Murderer Mystery 2's one. It's data transfer and saving part is completed (And tested), but I'm having trouble with the panel generation.
It shows no error and I already debugged it nothing went wrong but a new panel didn't create.
Here's my script:
02 | local rep = game:GetService( "ReplicatedStorage" ) |
03 | local remote = rep.Remotes:WaitForChild( "GetPlayerItemInfoCTC" ) |
04 | local remote 2 = rep.Remotes:WaitForChild( "SendPlayerItemInfoEvent" ) |
05 | local remote 3 = rep.Remotes:WaitForChild( "InventoryControlEvent" ) |
06 | local remote 4 = rep.Remotes:WaitForChild( "CloseAllGuisCTC" ) |
07 | local frame = script.Parent |
08 | local gui = frame.Parent |
09 | local panelHolder = frame:FindFirstChild( "BlankHolder" ) |
10 | local plr = game.Players.LocalPlayer |
11 | local itemModule = require(rep.Modules.ItemLibrary) |
12 | local contentProvider = game:GetService( "ContentProvider" ) |
18 | local function checkHorizontalNumber(id, line) |
22 | local preOperator = line - 1 |
23 | local operator = 4 * preOperator |
24 | local formula = id - operator |
29 | print ( "Invoking for info" ) |
30 | local itemInfo = remote:InvokeServer() |
33 | print ( "Printing inventory info" ) |
34 | for i, v in pairs (itemInfo) do |
36 | print ( "Creating information for panel" ) |
37 | local lineNumber = i / 4 |
38 | local HorizontalId = checkHorizontalNumber(i, 1 ) |
39 | local additional = HorizontalId - 1 |
40 | local additional 2 = lineNumber - 1 |
41 | local Coordinate = UDim 2. new( 0 , 135 * additional, 0 , 135 % additional 2 ) |
42 | print ( "Obtaining information for item" ) |
43 | local obtainedItemName, obtainedItemInfo = itemModule.GetItem(v) |
45 | if obtainedItemInfo then |
46 | print ( "Information obtained" ) |
47 | local itemTier = itemModule.TierValue(v) |
48 | local targetPanel = panelHolder:FindFirstChild( "Panel" ..i) |
50 | print ( "Panel already exists" ) |
51 | targetPanel.ToolName.Text = obtainedItemName |
52 | targetPanel.Image.Image = "rbxassetid://" ..obtainedItemInfo.image |
53 | local assetToPreload = { targetPanel.Image } |
54 | contentProvider:PreloadAsync(assetToPreload) |
56 | print ( "Creating new panel" ) |
57 | local newPanel = panelHolder.Panel 1 :Clone() |
58 | newPanel.Name = "Panel" ..i |
59 | newPanel.ToolName.Text = obtainedItemName |
60 | newPanel.Position = Coordinate |
61 | newPanel.Image.Image = "rbxassetid://" ..obtainedItemInfo.image |
62 | local assetToPreload = { newPanel.Image } |
63 | contentProvider:PreloadAsync(assetToPreload) |
66 | print ( "Ending function" ) |
For the item library module:
24 | [ "Wood Club" ] = { tier = "Starter" ;desc = "We might have stolen something from the local barbarians." ;kind = "Weapon" ;dmg = 25 ;image = 2263279249 } ; |
25 | [ "Alpha Sword" ] = { tier = "Special" ;desc = "For people who played during Alpha." ;kind = "Weapon" ;dmg = 25 ;image = 2263279249 } ; |
26 | [ "Universal Sword" ] = { tier = "???" ;desc = "The one and only mighty sword, created by WD32##:?#:##DE before universe even existed. Welded by only SpectrumDev himself. +Infinity damage" ;kind = "Weapon" ;dmg = 9001 ;image = 605035383 } |
29 | function module.GetItem(itemName) |
30 | print ( "Starting Module" ) |
31 | for Objname, values in pairs (tableOfItem) do |
32 | if itemName = = Objname then |
33 | return Objname, values |
38 | function module.TierValue(tierName) |
39 | for tier, value in pairs (tableOfTier) do |
40 | if tier = = tierName then |
Output:
1 Wood Club
Creating information for panel
Obtaining information for item
Starting Module
Information obtained
Panel already exists
13:32:03.214 - ContentProvider:PreloadAsync() failed for rbxassetid://2263279249
Ending function
2 Alpha Sword
Creating information for panel
Obtaining information for item
Starting Module
Information obtained
Creating new panel
13:32:03.748 - ContentProvider:PreloadAsync() failed for rbxassetid://2263279249
Ending function
Edit: I also need help with the ContentProvider preload async, I have no clue why it don't work.