local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local TweenService = game:GetService("TweenService")
local CLOUD_MODEL = script.Parent
local ALL_PATHS = CLOUD_MODEL:WaitForChild("AllPaths")
local PATHS = ALL_PATHS:GetChildren()
I’m trying to get all cloud models in each selected folder but I don’t know how to do that.
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SoundService = game:GetService("SoundService")
local TweenService = game:GetService("TweenService")
local CLOUD_MODEL = script.Parent
local ALL_PATHS = CLOUD_MODEL:WaitForChild("AllPaths")
local function GetClouds() : {Model}
local Result = {}
for _, x in ALL_PATHS:GetDescendants() do
local PathName = x.Name
if PathName:sub(1, 5) ~= "Cloud" or not tonumber(PathName:sub(6)) then continue end
table.insert(Result, x)
end
return Result
end
local Clouds = GetClouds()
If you want it so you can select a specific folder, I can do that for you. The code gets every instance under AllPaths and sees if they have a specific name. Assuming there are no other instances that have the name “cloud” and have a number after it then the code should work well
sub is a string method that basically splits up a string. For example if i had the string “cake” and I did String:sub(1, 2) I would get “ca”. For tonumber all it does is take a string and try to convert it into a number. If it cannot convert it, it will result in nil. For example tonumber(" 2 ") will be number 2.