Untitled
raw download clone
TEXT
views 25
,
size 6824 b
This is some code from the avatar editor I made.
```lua

local ItemsModule = require(game.ReplicatedStorage.Items) --Finding the event
local db = false -- debounce is set to false
local plr = game.Players.LocalPlayer  -Finding the players. This can also represent the children of the packpack
repeat wait() until workspace:WaitForChild(plr.Name):FindFirstChild("HumanoidRootPart")
local camera = workspace.CurrentCamera
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:wait()  -Finding the character, and locating the humaniod
char:WaitForChild'HumanoidRootPart'

camera.CameraType = Enum.CameraType.Custom
camera.CameraSubject = workspace:WaitForChild(plr.Name):FindFirstChild("Humanoid")

script.Parent.MainFrame.Close.MouseButton1Down:Connect(function()  --When the button is clicked, the MainFrame will become invisible. This is referring to the Close button
	script.Parent.MainFrame.Visible = false
	camera.CameraType = Enum.CameraType.Custom
	camera.CameraSubject = workspace:WaitForChild(plr.Name):FindFirstChild("Humanoid")
	plr.Character.Humanoid.WalkSpeed = 16
	plr.Character.Humanoid.JumpPower = 50
	for i,v in pairs(script.Parent.MainFrame.Displays:GetChildren()) do
		v.Holder.CanvasSize = UDim2.new(0,0,0,v.Holder.UIGridLayout.AbsoluteContentSize.Y)
	end
end)

script.Parent.Open.MouseButton1Down:Connect(function()  --When the button is clicked, the MainFrame will become visible. This is the open button.
	if script.Parent.MainFrame.Visible == false then   -If the MainFrame is visible then, it will get the items from the Displays (A frame with buttons on the item you would like to put on your avatar) It will then load in the new character you have,
		script.Parent.MainFrame.Visible = true
		camera.CameraType = Enum.CameraType.Scriptable
		local pos = (char.HumanoidRootPart.CFrame * CFrame.new(4,3,-7)).p
		camera.CFrame = CFrame.new(pos,char.Head.Position) * CFrame.new(5,0,0)
		plr.Character.Humanoid.WalkSpeed = 0
		plr.Character.Humanoid.JumpPower = 0
		wait()
		for i,v in pairs(script.Parent.MainFrame.Displays:GetChildren()) do
			v.Holder.CanvasSize = UDim2.new(0,0,0,v.Holder.UIGridLayout.AbsoluteContentSize.Y)
		end
	else
		script.Parent.MainFrame.Visible = false
		camera.CameraType = Enum.CameraType.Custom
		camera.CameraSubject = workspace:WaitForChild(plr.Name):FindFirstChild("Humanoid")
		plr.Character.Humanoid.WalkSpeed = 16
		plr.Character.Humanoid.JumpPower = 50
		wait()
		for i,v in pairs(script.Parent.MainFrame.Displays:GetChildren()) do
			v.Holder.CanvasSize = UDim2.new(0,0,0,v.Holder.UIGridLayout.AbsoluteContentSize.Y)
		end
	end
end)

script.Parent.MainFrame.Reset.MouseButton1Down:Connect(function()      --If this is clicked, the event 'Reset' will fire, causing the player to reset their character
	game.ReplicatedStorage.WearItem:FireServer({"Reset"})
end)

for i,v in pairs(script.Parent.MainFrame.TopBar:GetChildren()) do
	if v.Name ~= "BG" then
		v.MouseButton1Down:Connect(function()
			for ii,vv in pairs(script.Parent.MainFrame.Displays:GetChildren()) do
				vv.Visible = false
			end
			script.Parent.MainFrame.Displays:FindFirstChild(v.Name).Visible = true
			wait()
			for i,v in pairs(script.Parent.MainFrame.Displays:GetChildren()) do
				v.Holder.CanvasSize = UDim2.new(0,0,0,v.Holder.UIGridLayout.AbsoluteContentSize.Y)
			end
		end)
	end
end

script.Parent.MainFrame.RemoveHats.MouseButton1Down:Connect(function()
	for i,v in pairs(script.Parent.MainFrame.Displays.Premium.Holder:GetChildren()) do
		if v:IsA("Frame") then
			v.Equipped.Value = false
			v.BG.ImageColor3 = Color3.fromRGB(0, 182, 133)
		end
	end
	for i,v in pairs(script.Parent.MainFrame.Displays.Hats.Holder:GetChildren()) do
		if v:IsA("Frame") then
			v.Equipped.Value = false
			v.BG.ImageColor3 = Color3.fromRGB(0, 182, 133)
		end
	end
	game.ReplicatedStorage.WearItem:FireServer({"RemoveAll"})  --This event will reset your character, but it won't kill you. It will only remove the item that is taking place before you would like to select the new item.
end)

for i,v in pairs(ItemsModule.Items) do
	for ii,vv in pairs(v) do
		if script.Parent.MainFrame.Displays:FindFirstChild(i) then
			local temp = script.ItemTemplate:Clone()
			temp.Name = ii
			temp.ItemImage.Image = "https://www.roblox.com/Thumbs/Asset.ashx?width=110&height=110&assetId="..ii
			temp.Parent = script.Parent.MainFrame.Displays:FindFirstChild(i).Holder
			temp.ItemImage.MouseButton1Down:Connect(function()
				if db == false then
					db = true
					if temp.Equipped.Value == false then
						local count = 0
						for iii,vvv in pairs(temp.Parent:GetChildren()) do
							if vvv:IsA("Frame") then
								if vvv.Equipped.Value == true then
									count = count + 1
								end
							end
						end
						--Events

if temp.Parent.Parent.Name == "Hats" and count < 3 then
							temp.Equipped.Value = true
							temp.BG.ImageColor3 = Color3.fromRGB(85, 170, 255)
							game.ReplicatedStorage.WearItem:FireServer({"Wear", temp.Name, temp.Parent.Parent.Name})
						elseif temp.Parent.Parent.Name == "Shirts" and count < 1 then
							temp.Equipped.Value = true
							temp.BG.ImageColor3 = Color3.fromRGB(85, 170, 255)
							game.ReplicatedStorage.WearItem:FireServer({"Wear", temp.Name, temp.Parent.Parent.Name})
						elseif temp.Parent.Parent.Name == "Pants" and count < 1 then
							temp.Equipped.Value = true
							temp.BG.ImageColor3 = Color3.fromRGB(85, 170, 255)
							game.ReplicatedStorage.WearItem:FireServer({"Wear", temp.Name, temp.Parent.Parent.Name})
						elseif temp.Parent.Parent.Name == "Faces" and count < 1 then
							temp.Equipped.Value = true
							temp.BG.ImageColor3 = Color3.fromRGB(85, 170, 255)
							game.ReplicatedStorage.WearItem:FireServer({"Wear", temp.Name, temp.Parent.Parent.Name})
						elseif temp.Parent.Parent.Name == "Premium" and count < 3 then
							
								temp.Equipped.Value = true
								temp.BG.ImageColor3 = Color3.fromRGB(85, 170, 255)
								game.ReplicatedStorage.WearItem:FireServer({"Wear", temp.Name, temp.Parent.Parent.Name})
							
								
							
						end
					else
						temp.Equipped.Value = false
						temp.BG.ImageColor3 = Color3.fromRGB(0, 182, 133)
						game.ReplicatedStorage.WearItem:FireServer({"Remove", temp.Name})
					end
					wait(0.1)
					db = false  --After everything has functioned correctly, the debounce is set to false
				end
			end)
		end
	end
end
```

--FunnelCreator
--I did make this code, you can look up anything you want. You won't find it because it took 2 days to complete the whole avatar editor, On my Own. This is just a sample of the code. This wasn't copied by any source.
--Good day. -FunnelCreator

_
close fullscreen
Login or Register to edit or fork this paste. It's free.