I’m making a shop Gui. The player selects a collection and a scrolling frame pops up with all the items in the collection folder. I’m getting an error (below). There are items in the folder, why is it saying nil when there are items in the folder?
local ScrollingFrame = script.Parent.Parent.Parent.CollectionPanel.ScrollingFrame
local Table = {}
for i, OptionButton in pairs(ScrollingFrame:GetChildren()) do
if OptionButton:IsA("TextButton") then
OptionButton.MouseButton1Click:Connect(function()
local Folder = OptionButton.CollectionFolder.Value
for i, Item in pairs(Folder:GetChildren()) do
table.insert(Table, Item)
end
for i, TableItem in pairs(Table) do
local CloneFrame = script.Parent.ScrollingFrame.OptionFrame:Clone()
CloneFrame.Parent = script.Parent.ScrollingFrame
end
end)
end
end
Since it is saying attempt to index nul with ‘GetChildren’, this means that the Folder variable is nil. And with no other errors in relation to it, this means that CollectionFolder exists within each button as well. Therefore, one or multiple of the ObjectValues does not actually have a value, in turn returning nil.
Edit: Make sure that the folders you are referencing are in a location that the client can access. For example, do not put them in ServerStorage.
If it is located in ServerStorage, then the client can not access the folders, resulting in the values of some of the ObjectValues to become nil. If you want them to work correctly, I recommend ReplicatedStorage. The client has no access whatsoever to ServerStorage.