You can write your topic however you want, but you need to answer these questions:
- What do you want to achieve? Keep it simple and clear!
I want it to, when I select the hair, it will put it on the NPC on the viewpoint frame on the GUI - What is the issue? Include screenshots / videos if possible!
I’m trying to make it where on my GUI, it will add the hair on the NPC on the viewpoint frame, whatever hair you select, but it clones it to the StarterCharacter under the viewpoint frame because when i look in player GUI while the game is running, the Accessory is there when you select the hair but its not showing on the npc in the viewpoint frame - What solutions have you tried so far? Did you look for solutions on the Creator Hub?
I tried Malury Welden it to the NPC head, but that didn’t work. I also try making a refresh system for the viewpoint, where it will refresh after cloning when you select the hair that didn’t work
Here’s my GUI script
local function typewrite(object,text)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
script.Sound:Play()
wait(0.01)
end
end
local plr = game.Players.LocalPlayer
local mouse = game.Players.LocalPlayer:GetMouse()
local Character = script.Parent.Barbershop:WaitForChild("Character")
local Camera = workspace.CurrentCamera
Camera.CameraType = Enum.CameraType.Scriptable
local Charrr = script.Parent["Barbershop"].Character.CharPort.StarterCharacter
local Charport = script.Parent["Barbershop"].Character.CharPort
local CanMove = false
local playerGui = plr:WaitForChild("PlayerGui")
local Workspace = game:GetService("Workspace")
local ServerStorage = game:GetService("ReplicatedStorage")
local hairFolder = ServerStorage.Hair:WaitForChild("Male")
local screenGui = playerGui:WaitForChild("Barbershop")
local Barbershop = screenGui:WaitForChild("Barbershop")
local Hairs = Barbershop:WaitForChild("Hairs")
local container = Hairs:WaitForChild("ScrollingFrame")
local buttonTemplate = container:WaitForChild("Hairstyle")
for _, child in ipairs(container:GetChildren()) do
if child:IsA("TextButton") and child ~= buttonTemplate then
child:Destroy()
end
end
for _, model in ipairs(hairFolder:GetChildren()) do
if model:IsA("Accessory") then
local newButton = buttonTemplate:Clone()
newButton.Name = model.Name .. "Button"
newButton.Text = model.Name
newButton.Parent = container
newButton.Visible = true
newButton.MouseEnter:Connect(function()
print("click")
for _, child in ipairs(Charrr:GetChildren()) do
if child:IsA("Accessory") and child.Name ~= "Ears" and child.Name ~= "Nose" then
child:Destroy()
end
end
local head = Charrr:FindFirstChild("Head")
local newHair = model:Clone()
newHair.Parent = Charrr
Charrr.Humanoid:AddAccessory(newHair)
end)
newButton.MouseButton1Click:Connect(function()
print("Selected haircut:", model.Name)
-- Remove all current hair accessories
for _, child in ipairs(Charrr:GetChildren()) do
if child:IsA("Accessory") and child.Name ~= "Ears" and child.Name ~= "Nose" then
child:Destroy()
end
end
local head = Charrr:FindFirstChild("Head")
-- Clone selected hair
local selectedHair = model:Clone()
selectedHair.Name = "Hair2"
selectedHair.Parent = Charrr
Charrr.Humanoid:AddAccessory(selectedHair)
print("Cloned and added accessory:", model.Name)
end)
end
end
script.Parent["Barbershop"].Move.MouseButton1Down:Connect(function()
CanMove = true
end)
script.Parent["Barbershop"].Move.MouseButton1Up:Connect(function()
CanMove = false
end)
mouse.Button1Up:Connect(function()
CanMove = false
end)
local viewportFrame = script.Parent["Barbershop"].Character.CharPort
local objectRotationSpeed = 1
local object = viewportFrame:GetChildren()[1]
object:SetPrimaryPartCFrame(CFrame.new(91.77, 8.196, 576.209))
local lastMousePositionX = mouse.X
mouse.Move:Connect(function()
if CanMove == true then
local currentMousePositionX = mouse.X
local delta = currentMousePositionX - lastMousePositionX
object:SetPrimaryPartCFrame(object:GetPrimaryPartCFrame() * CFrame.Angles(0, math.rad(delta * objectRotationSpeed), 0))
lastMousePositionX = currentMousePositionX
wait()
end
end)
local HairPrice = 0
local BeardPrice = 0
local TotalPrice = 0
local Hair = nil
local Camera = workspace.CurrentCamera
local TweenService = game:GetService("TweenService")
local TI = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local Target = {CFrame = plr.Character:FindFirstChild("Head").CFrame}
local Tween2 = TweenService:Create(Camera,TI,Target)
script.Parent.Convo.Vender.Text = "Barber"
plr.PlayerGui.Main_Hud.Enabled = false
if plr.PlayerData.Slot1.SlotMade.Value == true then
if plr.PlayerData.Slot1.Gender.Value == "Male" then
local Hair = game.ReplicatedStorage.Character.Hairs.Male:FindFirstChild(plr.PlayerData.Slot1.Hair.Value):Clone()
Hair.Parent = Charrr
Hair.Name = "Hair"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
if plr.PlayerData.Slot1.Gender.Value == "Female" then
local Hair = game.ReplicatedStorage.Character.Hairs.Female:FindFirstChild(plr.PlayerData.Slot1.Hair.Value):Clone()
Hair.Parent = Charrr
Hair.Name = "Hair"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
Charrr.Head.face.Texture = plr.PlayerData.Slot1.Face.Value
Charrr.Shirt.ShirtTemplate = plr.PlayerData.Slot1.Shirts.Value
Charrr.Pants.PantsTemplate = plr.PlayerData.Slot1.Pants.Value
local SkinColor = BrickColor.new(plr.PlayerData.Slot1.SkinColor.Value)
for i, v in pairs(Charrr:GetDescendants()) do
if v:IsA("MeshPart") --[[or v.Name == "Head" ]]or v:IsA("Part") and v.Name ~= "HumanoidRootPart" then
v.BrickColor = SkinColor
end
end
--plr.Character.Humanoid.BodyHeightScale.Value = plr.PlayerData.Slot1.Height.Value
--plr.Character.Humanoid.BodyWidthScale.Value = plr.PlayerData.Slot1.Weight.Value
if plr.PlayerData.Slot1.Gender.Value == "Male" then
local Hat = game.ReplicatedStorage.Character.Accessories.Hats:FindFirstChild(plr.PlayerData.Slot1.Hat.Value):Clone()
Hat.Parent = Charrr
Hat.Name = "Hat"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
if plr.PlayerData.Slot1.Gender.Value == "Female" then
local Hat = game.ReplicatedStorage.Character.Accessories.Hats:FindFirstChild(plr.PlayerData.Slot1.Hat.Value):Clone()
Hat.Parent = Charrr
Hat.Name = "Hat"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
if plr.PlayerData.Slot1.Gender.Value == "Male" then
local Hat = game.ReplicatedStorage.Character.Accessories.Glasses:FindFirstChild(plr.PlayerData.Slot1.Glasses.Value):Clone()
Hat.Parent = Charrr
Hat.Name = "Glasses"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
if plr.PlayerData.Slot1.Gender.Value == "Female" then
local Hat = game.ReplicatedStorage.Character.Accessories.Glasses:FindFirstChild(plr.PlayerData.Slot1.Glasses.Value):Clone()
Hat.Parent = Charrr
Hat.Name = "Glasses"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
if plr.PlayerData.Slot1.Gender.Value == "Male" then
local Hat = game.ReplicatedStorage.Character.Accessories.Bags:FindFirstChild(plr.PlayerData.Slot1.Bag.Value):Clone()
Hat.Parent = Charrr
Hat.Name = "Bag"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
if plr.PlayerData.Slot1.Gender.Value == "Female" then
local Hat = game.ReplicatedStorage.Character.Accessories.Bags:FindFirstChild(plr.PlayerData.Slot1.Bag.Value):Clone()
Hat.Parent = Charrr
Hat.Name = "Bag"
Charrr.Humanoid.HeadScale.Value = 0.999
wait()
Charrr.Humanoid.HeadScale.Value = 1
end
if plr.PlayerData.Slot1.Gender.Value == "Male" then
local Shoe = game.ReplicatedStorage.Character.Shoes:FindFirstChild(plr.PlayerData.Slot1.Shoes.Value)
local Clone1 = Shoe:Clone()
Clone1.Parent = Charrr
Clone1.Name = "Shoes"
Charrr.LeftFoot:FindFirstChild("ShoeWeld").Part1 = Clone1
local Clone2 = Shoe:Clone()
Clone2.Parent = Charrr
Clone2.Name = "Shoes"
Charrr.RightFoot:FindFirstChild("ShoeWeld").Part1 = Clone2
end
if plr.PlayerData.Slot1.Gender.Value == "Female" then
local Shoe = game.ReplicatedStorage.Character.Shoes:FindFirstChild(plr.PlayerData.Slot1.Shoes.Value)
local Clone1 = Shoe:Clone()
Clone1.Parent = Charrr
Clone1.Name = "Shoes"
Charrr.LeftFoot:FindFirstChild("ShoeWeld").Part1 = Clone1
local Clone2 = Shoe:Clone()
Clone2.Parent = Charrr
Clone2.Name = "Shoes"
Charrr.RightFoot:FindFirstChild("ShoeWeld").Part1 = Clone2
end
Charrr.Parent = workspace
wait()
Charrr.Parent = script.Parent["Barbershop"].Character.CharPort
end
local Blur = Instance.new("BlurEffect")
Blur.Parent = game.Lighting
Blur.Name = "BarberBlur"
Blur.Size = 0
local TweenService = game:GetService("TweenService")
local TI = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local Target = {Size = 10}
local Tween3 = TweenService:Create(Blur,TI,Target)
local TweenService = game:GetService("TweenService")
local TI = TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.Out, 0, false, 0)
local Target = {Size = 0}
local Tween4 = TweenService:Create(Blur,TI,Target)
script.Parent.Chair.OnClientEvent:Connect(function()
Tween4:Play()
Camera.CameraType = Enum.CameraType.Custom
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
plr.PlayerGui.Main_Hud.Enabled = true
Blur:Destroy()
script.Parent.RemoveUi:FireServer()
end)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
typewrite(script.Parent.Convo.Convo, "Hola mi hermano... welcome to ''Babero Dominiccana'' where our cuts is flawless and to perfection. Do you need a haircut? ")
wait(1)
script.Parent.Convo.Yea.Visible = true
script.Parent.Convo.Nah.Visible = true
script.Parent.Convo.Nah.MouseButton1Click:Connect(function()
script.Click:Play()
typewrite(script.Parent.Convo.Convo,"Alright, just let me know if you need something.")
script.Parent.RemoveUi:FireServer()
Tween4:Play()
Camera.CameraType = Enum.CameraType.Custom
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
plr.PlayerGui.Main_Hud.Enabled = true
end)
script.Parent.Convo.Yea.MouseButton1Click:Connect(function()
script.Click:Play()
typewrite(script.Parent.Convo.Convo,"Alright, let me know what hairstyle you want.")
wait(1)
Tween3:Play()
script.Parent.Barbershop.Visible = true
script.Parent.Convo.Visible = false
if plr.PlayerData.Slot1.Gender.Value == "Male" then
for i, v in pairs(game.ReplicatedStorage.Character.Hairs.Male:GetChildren()) do
local Clone = script.None:Clone()
Clone.Parent = script.Parent.Barbershop.Hairs.ScrollingFrame
Clone.Name = v.Name
Clone.TextLabel.Text = v.Name
local randommm = math.random(1,3)
if randommm == 1 then
Clone.Price.Value = 150
elseif randommm == 2 then
Clone.Price.Value = 200
elseif randommm == 3 then
Clone.Price.Value = 250
end
end
end
if plr.PlayerData.Slot1.Gender.Value == "Female" then
for i, v in pairs(game.ReplicatedStorage.Character.Hairs.Female:GetChildren()) do
local Clone = script.None:Clone()
Clone.Parent = script.Parent.Barbershop.Hairs.ScrollingFrame
Clone.Name = v.Name
Clone.TextLabel.Text = v.Name
local randommm = math.random(1,3)
if randommm == 1 then
Clone.Price.Value = 150
elseif randommm == 2 then
Clone.Price.Value = 200
elseif randommm == 3 then
Clone.Price.Value = 250
end
end
end
for i, v in pairs(script.Parent.Barbershop.Hairs.ScrollingFrame:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
script.Click:Play()
for i, v in pairs(Charrr:GetDescendants()) do
if v:IsA("Accessory") and v.Name ~= "Ears" and v.Name ~= "Nose" and v.Name == "Hair" then
v:Destroy()
end
end
Hair = v.Name
local Clone = game.ReplicatedStorage.Character.Hairs.Male:FindFirstChild(Hair):Clone()
Clone.Parent = Charrr
Clone.Name = "Hair"
Charrr.Humanoid.HeadScale.Value = 0.999
Charrr.Parent = workspace
wait()
Charrr.Humanoid.HeadScale.Value = 1
Charrr.Parent = script.Parent["Barbershop"].Character.CharPort
HairPrice = v.Price.Value
script.Parent.Barbershop.Hairs.Price.Text = "Price: "..HairPrice
end)
end
end
script.Parent.Barbershop.Hairs.Purchase.MouseButton1Click:Connect(function()
script.Click:Play()
script.Parent.RemoteEvent:FireServer(Hair, HairPrice, "Hair")
if plr.PlayerData.Slot1.Cash.Value >= HairPrice then
script.Success:Play()
game.ReplicatedStorage.ApplyHair:FireServer(Hair)
else
script.Error:Play()
end
script.Parent.Barbershop.Hairs.Purchase.Visible = false
wait(1)
script.Parent.Barbershop.Hairs.Purchase.Visible = true
end)
script.Parent.Barbershop.Exit.MouseButton1Click:Connect(function()
script.Click:Play()
Tween4:Play()
Camera.CameraType = Enum.CameraType.Custom
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, true)
plr.PlayerGui.Main_Hud.Enabled = true
Blur:Destroy()
script.Parent.RemoveUi:FireServer()
end)
end)