How do i select multiple childern of the same class?

Basically I want the script to select all models within a folder however I’m not sure how to.

Heres my script.

		if game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model") then
			clonegui.Parent = gui.SpawnProperties.VehiclesFrame.VehicleCloneFrame
			clonegui.Text = game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model").Name
		end
		end)
end)

Loop through it.

for i,v in pairs(path:GetChildren()) do
if v:IsA("Model") then
--do stuff
end
end

Still getting the same result as I was before

Heres the updated script

if game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model") then
			local path = game:GetService("ReplicatedStorage").Vehicles
			for i,v in pairs(path:GetChildren()) do
				if v:IsA("Folder") then v:FindFirstChildOfClass("Model")
					clonegui.Parent = gui.SpawnProperties.VehiclesFrame.VehicleCloneFrame
					clonegui.Text = v
				end
			end
			
		end
~~`

change path to your folder you want to loop on
nvm I didn’t check the whole script

then here

if game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model") then
			local Path = game:GetService("ReplicatedStorage").Vehicles
			for i,v in pairs(Path:GetChildren()) do
				if v:IsA("Folder") then
					clonegui.Parent = gui.SpawnProperties.VehiclesFrame.VehicleCloneFrame
					clonegui.Text = v.Name
				end
			end
		end

That doesn’t work to be more specific the scripts meant to clone the gui for every model found within the folder

ok works fine now when i removed 70% of the script

local Path = game:GetService("ReplicatedStorage").Vehicles

for i,v in pairs(Path:GetChildren()) do
	if v:IsA("Folder") then
		local clonegui = script.Parent.GuiThingy:Clone()
		clonegui.Text = v.Name
		clonegui.Parent = gui.SpawnProperties.VehiclesFrame.VehicleCloneFrame
	end
end
if game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model") then
	local Path = game:GetService("ReplicatedStorage").Vehicles
	for i,v in pairs(Path:GetChildren()) do
		if v:IsA("Folder") then
            local Clone = clonegui:Clone()
			Clone.Parent = gui.SpawnProperties.VehiclesFrame.VehicleCloneFrame
			Clone.Text = v.Name
		end
	end
end
1 Like

you didnt put the clone thingy on the loop so it wont work then

That still wont work it’s only finding the vehicles folder what it’s intended to do is find a folder within the path then find a model within the folder.

I don’t know if anyone knows what you’re really trying to achieve, any better way to explain it?

Okay to put it simply I want the script to find a folder which is within the path then to find all of the childs in that folder which are of the model class then clone a gui for every model found.

This what you mean?

if game:GetService("ReplicatedStorage").Vehicles:FindFirstChildOfClass("Folder"):FindFirstChildOfClass("Model") then
	local Path = game:GetService("ReplicatedStorage").Vehicles
	for i,v in pairs(Path:GetChildren()) do
		if v:IsA("Folder") then
			for i, v in pairs(v:GetChildren()) do
				if v:IsA("Model") then
					local Clone = clonegui:Clone()
					Clone.Parent = v
					Clone.Text = v.Name
				end
			end
		end
	end
end

Yep that works however It’s not cloning a gui for every single model found

Now try, oops (I edited it)

characterssss

Yep it works now thanks a lot.

:+1:

1 Like