I have a data store for a list of slots in an item storage gui. I want to load the images of the items stored on each slot when a player joins the game, but for some reason, it kept giving me an “Infinite yield possible” error
local serverstorage = game:GetService("ServerStorage")
local replicatedstorage = game:GetService("ReplicatedStorage")
local folder = Instance.new("Folder")
folder.Name = "Bank_Storage"
folder.Parent = player
for i = 1, 20, 1 do
local Slot = Instance.new("StringValue")
Slot.Name = "Slot".. i
Slot.Parent = player.Bank_Storage
for i = 1, 20, 1 do
if i <= 5 then
rownumber = 1
elseif i > 5 and i <= 10 then
rownumber = 2
elseif i > 10 and i <= 15 then
rownumber = 3
elseif i > 15 and i <= 20 then
rownumber = 4
for _, v in pairs(serverstorage.Items:GetChildren()) do
if player.Bank_Storage:WaitForChild("Slot".. i).Value == v.Name then
player.PlayerGui:WaitForChild("UI").StorageUI.Storage:WaitForChild("Row".. rownumber):WaitForChild("Slot".. i).Image = v.TextureId
player.PlayerGui:WaitForChild("UI").StorageUI.Storage:WaitForChild("Row".. rownumber):WaitForChild("Slot".. i).ImageColor3 = Color3.new(255, 255, 255)
Please let me know if you want any other information.
Yes, and I am saying that you are most likely making the slots on the client. If I am correct, the server doesn’t see those slots, meaning the server will have an infinite wait. So, again, you should probably have the client request the slot data, and have it handle the slots there.
I found out what was wrong as soon as I saw the picture of the slots and image buttons. Its looking for a Image button in row 2 called “Slot6” but they are only name “Slot(1-5)” instead of having 6, you might have to rename all of those image buttons in each row and dont make them start at one but instead start at what it should be in that row.
If you are just trying to sort the buttons then I suggest just using UIListLayout becuase it’s really helpful for this case.