Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Hair Changer Customization GUI for players character, Hair won't overlap despite duplication of GUI?

Asked by 5 years ago

Hi i'm having trouble creating a hair changing GUI that inserts hair into the folder that is in a players head, see what I want is for the Hair Changer to get 2 MeshParts (Hair meshes) to overlap eachother which you can see in this video here: https://www.youtube.com/watch?v=lGcBR4AjhWQ&list=LL8Pi3gtj9ud-VM4RryqHL_g&index=8&t=134s

I want this so the player is able to have a piece of dyed hair and their own unique combination (but don't worry about the colours I made coloured meshparts in a hair folder in ServerStorage and have a button for each hair mesh)

Now I have tried to do this by duplicating the HairGui which is a scrollingframe with buttons for each Hair/Meshpart and I tried renaming all the variables like folder to folder2 in the second HairGui which we'll call HairGui2.

If you're wondering about the script I followed this tutorial from the timestamp 14:33 (for the FolderCreate) script as I missed out the script that removes the players hair when they spawn because im using a StarterCharacter in StarterPlayer so they all spawn bald anyway The real part starts at the timestamp 20:18

https://www.youtube.com/watch?v=aar2K6WSn4s

Now here are my scripts which I followed during the tutorial

FolderCreate in ServerScriptService, as you can see I pasted the first FolderCreate function and put 2 after it (which you dont see in the video) to try and make my overlapping of 2 hair models on the player work

01game.Players.PlayerAdded:Connect(function(player)
02    player.CharacterAdded:Connect (function(char)
03        local folder = Instance.new("Folder")
04 
05        folder.Parent = char.Head
06        folder.Name = "Hair"
07 
08    end)
09end)
10 
11 
12--2nd Folder
13game.Players.PlayerAdded:Connect(function(player)
14    player.CharacterAdded:Connect (function(char)
15        local folder2 = Instance.new("Folder")
View all 23 lines...

--EmoHair1 game.ReplicatedStorage.HairEvents.HairEvent1.OnServerEvent:Connect(function(plr) local storage = game.ReplicatedStorage.Hair.EmoHair1 local char = plr.Character

01if char:FindFirstChild("Humanoid") then
02    local folder = char.Head.Hair
03 
04    folder:ClearAllChildren()
05 
06    local head = char.Head
07    local New_Hair = storage:Clone()
08    New_Hair.Parent = folder
09    New_Hair.Position = head.Position
10    local weld = Instance.new("Weld")
11    weld.Parent = New_Hair
12    weld.Part0,weld.Part1 = head,New_Hair
13    weld.C0 = CFrame.new(0,0.6,0)
14    weld.C1 = head.HairAttachment.CFrame
15 
16end

end)

--EmoHair1!Dye game.ReplicatedStorage.HairEvents.HairEvent2.OnServerEvent:Connect(function(plr) local storage = game.ReplicatedStorage.Hair.EmoHair1DYE local char = plr.Character

01if char:FindFirstChild("Humanoid") then
02    local folder = char.Head.Hair
03 
04    folder:ClearAllChildren()
05 
06    local head = char.Head
07    local New_Hair = storage:Clone()
08    New_Hair.Parent = folder
09    New_Hair.Position = head.Position
10    local weld = Instance.new("Weld")
11    weld.Parent = New_Hair
12    weld.Part0,weld.Part1 = head,New_Hair
13    weld.C0 = CFrame.new(0,0.6,0)
14    weld.C1 = head.HairAttachment.CFrame
15 
16end

end)

I think the main culprit of my problem is the folder:ClearAllChildren() as it clears away both hair/meshmodels in the players head folders, HairFolder1 and HairFolder2

If you're wondering what I mean, I tried to tackle my problem by copying this script and naming it HairScript2 and replacing variables with 2's on the ends of them so HairScript would only clear the Hair/MeshParts in HairFolder1 and the same with HairScript2 with HairFolder2

HairFolder2 in ServerScriptService

01--BuzzCut1
02game.ReplicatedStorage.HairEvents.HairEvent3.OnServerEvent:Connect(function(plr)
03    local storage = game.ReplicatedStorage.Hair.BuzzCut1
04    local char = plr.Character
05 
06    if char:FindFirstChild("Humanoid") then
07        local folder2 = char.Head.Hair2
08 
09        folder2:ClearAllChildren()
10 
11        local head = char.Head
12        local New_Hair = storage:Clone()
13        New_Hair.Parent = folder2
14        New_Hair.Name = "BuzzCutU1"
15        New_Hair.Position = head.Position
View all 47 lines...

Alas, this did not work and both scripts end up clearing both the folders children (Hair/Meshparts) like so:

HairScript --> ClearChildren() in character.Head.folder1 HairScript2 --> ClearChildren() in character.Head.folder2

That is what I hope for but both do HairScript --> ClearChildren() in character.Head.folder1 AND folder2 HairScript2 --> ClearChildren() in character.Head.folder2 AND folder1

That is what I not want

discord me for screenshots and details please

Randy Butternubs #7224

Answer this question