local g=function()for g,X in pairs(Content:GetChildren())do if X~=UIGrid then X:Destroy()end end end local X=function(g)local X=(g:GetChildren())[1]assert(X,"\091\069\114\114\111\114\093 \067\104\097\114\097\099\116\101\114 \100\111\101\115\110\'\116 \101\120\105\115\116 \105\110 \109\111\100\117\108\101 "..g.Name)local m=Instance.new("\086\105\101\119\112\111\114\116\070\114\097\109\101")m.Name=g.Name m.Parent=Content m.BorderSizePixel=0 m.BackgroundColor3=Color3.fromRGB(25,25,25)local f=(game.ServerStorage.Extra:WaitForChild("\085\073\067\111\114\110\101\114")):Clone()f.Parent=m local E=X:Clone()E.Parent=m local A=Instance.new("\067\097\109\101\114\097")A.Parent=m A.CFrame=CFrame.new(((E:WaitForChild("\072\101\097\100")).CFrame*CFrame.new(0,0,-8)).Position+Vector3.new(3,-2,0),E.Head.Position)A.FieldOfView=30 m.CurrentCamera=A local o=Instance.new("\084\101\120\116\066\117\116\116\111\110")o.Parent=m o.Size=UDim2.new(1,0,1,0)o.BackgroundTransparency=1 o.Text=""o.MouseButton1Click:Connect(function()if Debounce then return end Debounce=true SelectedCharacter.Value=g wait(1)Debounce=false end)end local m=function()g()local m=GetCellSize:InvokeClient(Player)UIGrid.CellSize=UDim2.new(0,m,0,m)for g,m in pairs(Characters:GetChildren())do X(m)end end m()

local Clear = function()
	for _,v in pairs(Content:GetChildren()) do
		if v ~= UIGrid then
			v:Destroy()
		end
	end
end

local Add = function(char)
	local charPrev = char:GetChildren()[1]
	assert(charPrev,"[Error] Character doesn't exist in module " .. char.Name)
	
	-- base frame
	local ViewportFrame = Instance.new("ViewportFrame")
	ViewportFrame.Name = char.Name
	ViewportFrame.Parent = Content
	ViewportFrame.BorderSizePixel = 0
	ViewportFrame.BackgroundColor3 = Color3.fromRGB(25,25,25)
	local Uicorner = game.ServerStorage.Extra:WaitForChild("UICorner"):Clone()
	Uicorner.Parent = ViewportFrame
	
	-- character preview
	local clone = charPrev:Clone()
	clone.Parent = ViewportFrame
	
	-- camera
	local camera = Instance.new("Camera")
	camera.Parent = ViewportFrame
	camera.CFrame = CFrame.new(
		(clone:WaitForChild("Head").CFrame * CFrame.new(0,0,-8)).Position
		+ Vector3.new(3,-2,0), 
		clone.Head.Position
	)
	camera.FieldOfView = 30
	
	ViewportFrame.CurrentCamera = camera
	
	-- button
	local button = Instance.new("TextButton")
	button.Parent = ViewportFrame
	button.Size = UDim2.new(1,0,1,0)
	button.BackgroundTransparency = 1
	button.Text = ""
	
	
	button.MouseButton1Click:Connect(function()
		if Debounce then return end
		Debounce = true;
		SelectedCharacter.Value = char
		wait(1)
		Debounce = false
	end)
end

local Refresh = function()
	Clear();
	local cellsize = GetCellSize:InvokeClient(Player)
	UIGrid.CellSize = UDim2.new(0,cellsize,0,cellsize)
	for _,v in pairs(Characters:GetChildren()) do
		Add(v);
	end
end

Refresh();
