#How do I wait for descandents on the Client?

1 messages · Page 1 of 1 (latest)

bright lance
#

I wanna get the descandents of a folder on the client but the script always runs before everything is finished loading and I dont wanna just put a task.wait(10) cause what if low end devices need 15 secs to load everything and the high end devices would only need 3 secs.

stuck loom
#

Under what context? When joining?

#

game:IsLoaded()

bright lance
#

so I tried this actually

if not game:IsLoaded() then
    game.Loaded:Wait()
end

but it doesnt seem to really work

#

could it not work cause im testing in studio?

stuck loom
bright lance
#
repeat task.wait()
until game:IsLoaded()

local worlds = game.Workspace:WaitForChild("worlds"):GetChildren()
local clientObj = {}

for _, world in ipairs(worlds) do
    local trailsFolder = world:WaitForChild("trails")
    local trails = trailsFolder:GetChildren()

    for _, trail in ipairs(trails) do
        local obbyFolder = trail:WaitForChild("obby")
        local obbyParts = obbyFolder:GetChildren()

        for _, obbyPart in ipairs(obbyParts) do
            if obbyPart:FindFirstChild("ClientObject") then
                table.insert(clientObj, obbyPart)
            end
        end
    end
end

print(clientObj)

the array still is empty

stuck loom
bright lance
#

I tought that would be too performance taking

stuck loom
#

you're using nested loop

#

theres no difference

bright lance
#

there is

#

imagine theres like 1000 parts in assets and i gotta loop through all that

#

its unnecessary

#

thats why im skipping the unneeded folders

stuck loom
#

so oyu're collecting the clientobject of each trails and obby

#

use collectionservice

bright lance
#

im never gonna fucking touch collectionservice again

#

its so ahh

stuck loom
#

why not?

bright lance
#

cause you can like only get the items from collectionservice wehn they are in your render distance

stuck loom
#

hmm

bright lance
#

idk the jtoh clientobject framework also loops through the whole workspace but i dont understand how it works for them that everything is loaded 😭

#

o yea

stuck loom
#

is tehre even an object named ClientObject??

stuck loom
bright lance
#

ClientObject is the bool value

stuck loom
#

oh the bool

bright lance
#

maybe ima send a signal from the server wehn someone enters a trail and then im gonna run that

#

that would also be less performance taking

stuck loom
#

i mean sure

bright lance
#

ig thats the best way to do it then i can also decide which obbies to load wehn and make it work on low end devices