How do I get all cloud models?

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.

Try this:

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

I dunno what PathName:sub and tonumber does but I will try it O_O

Nice it works! :smiley: By the way, is there a way to mention every item in a table? Just asking.

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.

What do you mean mention every item in the table?

Oh okay thank you. I’ll try learning that! :smiley:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.