Hello and thank you for looking at this thread!
I am having an issue with my code detecting items inside of a player folder.
In my game, I have created a folder named “inventory” for every player that joins. Said folder is filled with “String Value” objects as players collect items of the same name on the game. The picture below shows an example of my player character after having picked 2 items (BucketHat and Crown).
IMAGE 1
However, when I attempt to see what is inside of the folder via scripts, the code states it is empty. To test this I made a tool that once clicked prints all the folders inside of my player character along with the objects inside each one of them. Oddly, it says the “inventory” folder is empty despite having the aforementioned 2 items. The output can be seen below:
IMAGE 2
I took the liberty of including the code inside the debug tool below:
tool = script.Parent
tool.Equipped:Connect(function()
print("Equipped Debug Tool")
end)
tool.Activated:Connect(function()
for _,v in pairs(game.Players.Nanonaitor:GetChildren()) do
print("Folder: "..v.Name.." ------- x"..#game.Players.Nanonaitor[v.Name]:GetChildren())
for _,x in pairs(game.Players.Nanonaitor[v.Name]:GetChildren()) do
print(" Obj: "..x.Name)
end
end
print("----------------END----------------")
end)
----------
tool.Unequipped:Connect(function()
print("Unequipped Debug Tool")
end)
tool.Deactivated:Connect(function()
print("TOOL DEACTIVATED")
end)
I also messed with the folders by deleting/adding objects randomly. Oddly I got the exact same output as seen in IMAGE 2. I have looked online but am unsure if the player objects have to be updated somehow via code or what other thing may be causing this error. I appreciate any help/suggestions.