Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why can I not iterate through the children of a folder?

Asked by 5 years ago

So I've been trying to iterate through the children of a folder located in ReplicatedStorage. It contains IntValues that I need to read the value of, so I can store them in a table and then store the table in a DataStore, however it doesn't work.I can iterate just fine throught the children of ReplicatedStorage, but not through the folder in ReplicatedStorage.

I have tried this with both a local script and a normal script. Here is my code:

Local Script:

Players = game:GetService("Players")
repstorage = game:GetService("ReplicatedStorage")

while wait(1) do
    for i,v in pairs(repstorage:FindFirstChild(Players.LocalPlayer.Name.."ItemFolder"):GetChildren()) do
        print("object")
    end
end

Normal Script:

Players = game:GetService("Players")
repstorage = game:GetService("ReplicatedStorage")

while wait() do
    for _, plr in pairs(Players:GetPlayers()) do
        for _, v in pairs(repstorage:FindFirstChild(plr.Name.."ItemFolder"):GetChildren()) do
            print("children")
        end
    end
end

The local script iterates through the children, but the normal script doesn't. How can I do this with a normal script?

0
You've probably created this folder and its children from a localscript, making it client-side only. RubenKan 3615 — 5y
0
Thanks, that worked FriendlySniperZ 5 — 5y

Answer this question