How would i grab every instance inside of a frame using a server script?

Hello developers!

I am trying to make a quiz creator/editor system for one of my projects. However, i cant seem to get any instance to clone from my frame to the server script. The local script detects the click and grabs every item in the scrollingframe into a table and sends that table to the server script which goes through it one by one and clones all of them into the formBase
local script:

local TS = game:GetService("TweenService")
local lib = game.ReplicatedStorage.Library
local item = {}
script.Parent.MouseEnter:Connect(function()
	TS:Create(script.Parent.Parent.UIStroke, TweenInfo.new(0.2), {Color = Color3.new(0.333333, 0.666667, 1)}):Play()
	TS:Create(script.Parent, TweenInfo.new(0.2), {TextColor3 = Color3.new(0.333333, 0.666667, 1)}):Play()
end)
script.Parent.MouseLeave:Connect(function()
	TS:Create(script.Parent.Parent.UIStroke, TweenInfo.new(0.2), {Color = Color3.new(0, 0, 0)}):Play()
	TS:Create(script.Parent, TweenInfo.new(0.2), {TextColor3 = Color3.new(0, 0, 0)}):Play()
end)
script.Parent.MouseButton1Click:Connect(function()

	game.ReplicatedStorage.UpdatequizInfo:FireServer(script.Parent.Parent.Parent.Frame.QuizName.TextBox.Text,script.Parent.Parent.Parent.Frame.Sub.SelectSub.Text,item)
	wait(0.1)

	wait(5)
	for _,v in pairs(script.Parent.Parent.Parent.Parent.Parent.Parent.Form.ScrollingFrame:GetDescendants()) do
		if v:IsA("Frame") then
			if v.Name == "MultiChoice" or v.Name == "ShortResponce" then
		
		table.insert(item,v)
		v:Destroy()
	
	game.ReplicatedStorage.addQuiz:FireServer()
			end
		end
	end
end)

server script:

local TS = game:GetService("TweenService")
local lib = game.ReplicatedStorage.Library
local subject = "Nil"
local name = "Nil"
local items = {}
game.ReplicatedStorage.UpdatequizInfo.OnServerEvent:Connect(function(plr,n,sub,instances)
	subject = tostring(sub)
	name = tostring(n)
	for _,v in pairs(instances) do
		table.insert(items,tostring(v))
		print(v)
	end
end)
script.Parent.MouseEnter:Connect(function()
	TS:Create(script.Parent.Parent.UIStroke, TweenInfo.new(0.2), {Color = Color3.new(0.333333, 0.666667, 1)}):Play()
	TS:Create(script.Parent, TweenInfo.new(0.2), {TextColor3 = Color3.new(0.333333, 0.666667, 1)}):Play()
end)
script.Parent.MouseLeave:Connect(function()
	TS:Create(script.Parent.Parent.UIStroke, TweenInfo.new(0.2), {Color = Color3.new(0, 0, 0)}):Play()
	TS:Create(script.Parent, TweenInfo.new(0.2), {TextColor3 = Color3.new(0, 0, 0)}):Play()
end)
game.ReplicatedStorage.addQuiz:Connect(function()

	local formBase = lib.FormBase:Clone()
	formBase.Parent = game.ReplicatedStorage.Quizes[subject]
	formBase.Name = name
	local button = lib.QuizButton:Clone()
	button.shadowHolder.Frame.Form.Text = name
	button.Parent = 	script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.QuizAddPrompt.Sections[subject].Frame
	button.shadowHolder.Frame.Form.Name = name
	script.Parent.Parent.Parent.Parent.Parent.Parent.Parent.Parent.LT.Editor.Visible = false
	print("BreakPoint")
	for _,v in pairs(items) do
		local frame = game.ReplicatedStorage.Library:FindFirstChild(v)
		if frame:IsA("Frame") then
			if v.Name == "MultiChoice" or v.Name == "ShortResponce" then
				local clone = v:Clone()
				clone.close:Destroy()
				clone.Submit.Visible = true
				clone.Parent = formBase.Form.ScrollingFrame
				print(clone.Name)
				print("LoadedAllItems")
			end
		end
	end
end)
snippets
--client  MouseButton1Click function
script.Parent.MouseButton1Click:Connect(function()
	game.ReplicatedStorage.UpdatequizInfo:FireServer(script.Parent.Parent.Parent.Frame.QuizName.TextBox.Text,
		script.Parent.Parent.Parent.Frame.Sub.SelectSub.Text,script.Parent.Parent.Parent.Parent.Parent.Parent
			.Form.ScrollingFrame:GetChildren())
	wait(0.1)
	wait(5)
	game.ReplicatedStorage.addQuiz:FireServer()
end)

--server  OnServerEvent function
game.ReplicatedStorage.UpdatequizInfo.OnServerEvent:Connect(function(plr, n, sub, instances)
	subject = tostring(sub)
	name = tostring(n)
	items = instances
end)
1 Like

Thank you. I will try this out!

unfortunatly it didnt work :frowning: thanks for helping though!