local A=game:GetService("\082\101\112\108\105\099\097\116\101\100\083\116\111\114\097\103\101")local f=game:GetService("\080\108\097\121\101\114\115")local m=game:GetService("\083\116\097\114\116\101\114\071\117\105")local x=game:GetService("\082\117\110\083\101\114\118\105\099\101")local n=game:GetService("\076\105\103\104\116\105\110\103")local N=game:GetService("\085\115\101\114\073\110\112\117\116\083\101\114\118\105\099\101")local v=A.AvatarEditor local t=require(v.AvatarEditorClient)local u=require(script.Icon)local M=require(script.Distort)local w=f.LocalPlayer local Y=require((w:WaitForChild("\080\108\097\121\101\114\083\099\114\105\112\116\115")):WaitForChild("\080\108\097\121\101\114\077\111\100\117\108\101"))local G=Y:GetControls()local U=w.CameraMinZoomDistance local j=n:FindFirstChildWhichIsA("\083\117\110\082\097\121\115\069\102\102\101\099\116")local a=j and j.Enabled or false local P=(((((u.new()):setName("\065\118\097\116\097\114\069\100\105\116\111\114")):setImage("\114\098\120\097\115\115\101\116\058\047\047\116\101\120\116\117\114\101\115\047\117\105\047\073\109\097\103\101\083\101\116\047\076\117\097\065\112\112\047\105\109\103\095\115\101\116\095\050\120\095\051\046\112\110\103")):set("\105\099\111\110\082\101\099\116\079\102\102\115\101\116",Vector2.new(158,375))):set("\105\099\111\110\082\101\099\116\083\105\122\101",Vector2.new(48,53))):setCaption("\065\118\097\116\097\114 \069\100\105\116\111\114")t.Started:Connect(function()G:Disable()N.ModalEnabled=true m:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,false)M.Start()w.CameraMinZoomDistance=5 if j then j.Enabled=false end end)t.Loaded:Connect(function() end)t.PermissionFailed:Connect(function() end)t.Destroyed:Connect(function()M.Stop()m:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList,true)G:Enable()N.ModalEnabled=false w.CameraMinZoomDistance=U if j then j.Enabled=a end end)x:BindToRenderStep("\065\118\097\116\097\114\069\100\105\116\111\114",Enum.RenderPriority.Camera.Value,function(A)local f=t:GetAlpha()M.Position=UDim2.new(-0.3*f,0,0,0)M.Size=UDim2.new(.9,0,.9,0)t:OnRenderStep(A)end)P.toggled:Connect(function(A)if A then t:Load()else t:Destroy()end end)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local Run = game:GetService("RunService")
local Lighting = game:GetService("Lighting")
local UserInput = game:GetService("UserInputService")

local AvatarEditor = ReplicatedStorage.AvatarEditor
local AE = require(AvatarEditor.AvatarEditorClient)
local Icon = require(script.Icon)
local Distort = require(script.Distort)

local player = Players.LocalPlayer

local playerModule = require(player:WaitForChild("PlayerScripts"):WaitForChild("PlayerModule"))
local controlModule = playerModule:GetControls()

local defaultMinZoom = player.CameraMinZoomDistance

local sunrays = Lighting:FindFirstChildWhichIsA("SunRaysEffect")
local defaultSunrays = sunrays and sunrays.Enabled or false

local avatarIcon = Icon.new()
:setName("AvatarEditor")
:setImage("rbxasset://textures/ui/ImageSet/LuaApp/img_set_2x_3.png")
:set("iconRectOffset", Vector2.new(158, 375))
:set("iconRectSize", Vector2.new(48, 53))
:setCaption("Avatar Editor")


AE.Started:Connect(function()
	controlModule:Disable()
	UserInput.ModalEnabled = true
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
	Distort.Start()
	player.CameraMinZoomDistance = 5
	
	if sunrays then
		sunrays.Enabled = false
	end
end)

AE.Loaded:Connect(function()
	
end)

AE.PermissionFailed:Connect(function()
	
end)

AE.Destroyed:Connect(function()
	Distort.Stop()
	StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
	controlModule:Enable()
	UserInput.ModalEnabled = false
	player.CameraMinZoomDistance = defaultMinZoom
	
	if sunrays then
		sunrays.Enabled = defaultSunrays
	end
end)

Run:BindToRenderStep("AvatarEditor", Enum.RenderPriority.Camera.Value, function(delta)
	local alpha = AE:GetAlpha()
	Distort.Position = UDim2.new(-0.3 * alpha, 0, 0, 0)
	Distort.Size = UDim2.new(0.9, 0, 0.9, 0)
	AE:OnRenderStep(delta)
end)


avatarIcon.toggled:Connect(function(isSelected)
	if isSelected then
		AE:Load()
	else
		AE:Destroy()
	end
end)