-- EchoAUS Custom Health Gui
-- All this script does is put everything where it's supposed to be.


local function EnableScripts(i)
	local t = string.split(i.Name, ".")
	if t[#t] == "lua" and i:IsA("BaseScript") then
		i.Name = table.concat(t, ".", 1, #t - 1)
		i.Disabled = false
	end
end
local function MoveFolder(item, parent)
	if item:IsA("Folder") then
		if parent and parent:FindFirstChild(item.Name) then
			for _, i in ipairs (item:GetChildren()) do
				MoveFolder(i, parent[item.Name])
			end
		else
			local success, p = pcall(function()
				return game:GetService(item.Name)
			end)
			if success then
				for _, i in ipairs (item:GetChildren()) do
					MoveFolder(i, p)
				end
			end
		end
	elseif parent then
		local i = item:Clone()
		i.Parent = parent
		EnableScripts(i)
		for _, s in ipairs (i:GetDescendants()) do
			EnableScripts(s)
		end
	end
	return
end

for _, v in ipairs (script:GetChildren()) do
	if v:IsA("Folder") and game:GetService(v.Name) then
		MoveFolder(v)
	end
end

local parent = script.Parent
if parent:IsA("Model") then
	parent:Destroy()
end
