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
01 | game.Players.PlayerAdded:Connect( function (player) |
02 | player.CharacterAdded:Connect ( function (char) |
03 | local folder = Instance.new( "Folder" ) |
05 | folder.Parent = char.Head |
13 | game.Players.PlayerAdded:Connect( function (player) |
14 | player.CharacterAdded:Connect ( function (char) |
15 | local folder 2 = Instance.new( "Folder" ) |
17 | folder 2. Parent = char.Head |
18 | folder 2. Name = "Hair2" |
23 | Now here is the HairScript also in ServerScriptService (which you see in the video) |
--EmoHair1
game.ReplicatedStorage.HairEvents.HairEvent1.OnServerEvent:Connect(function(plr)
local storage = game.ReplicatedStorage.Hair.EmoHair1
local char = plr.Character
01 | if char:FindFirstChild( "Humanoid" ) then |
02 | local folder = char.Head.Hair |
04 | folder:ClearAllChildren() |
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.Part 0 ,weld.Part 1 = head,New_Hair |
13 | weld.C 0 = CFrame.new( 0 , 0.6 , 0 ) |
14 | weld.C 1 = head.HairAttachment.CFrame |
end)
--EmoHair1!Dye
game.ReplicatedStorage.HairEvents.HairEvent2.OnServerEvent:Connect(function(plr)
local storage = game.ReplicatedStorage.Hair.EmoHair1DYE
local char = plr.Character
01 | if char:FindFirstChild( "Humanoid" ) then |
02 | local folder = char.Head.Hair |
04 | folder:ClearAllChildren() |
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.Part 0 ,weld.Part 1 = head,New_Hair |
13 | weld.C 0 = CFrame.new( 0 , 0.6 , 0 ) |
14 | weld.C 1 = head.HairAttachment.CFrame |
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
02 | game.ReplicatedStorage.HairEvents.HairEvent 3. OnServerEvent:Connect( function (plr) |
03 | local storage = game.ReplicatedStorage.Hair.BuzzCut 1 |
04 | local char = plr.Character |
06 | if char:FindFirstChild( "Humanoid" ) then |
07 | local folder 2 = char.Head.Hair 2 |
09 | folder 2 :ClearAllChildren() |
11 | local head = char.Head |
12 | local New_Hair = storage:Clone() |
13 | New_Hair.Parent = folder 2 |
14 | New_Hair.Name = "BuzzCutU1" |
15 | New_Hair.Position = head.Position |
16 | local weld = Instance.new( "Weld" ) |
17 | weld.Parent = New_Hair |
18 | weld.Part 0 ,weld.Part 1 = head,New_Hair |
19 | weld.C 0 = CFrame.new( 0 , 0.85 , 0 ) |
20 | weld.C 1 = head.HairAttachment.CFrame |
26 | game.ReplicatedStorage.HairEvents.HairEvent 4. OnServerEvent:Connect( function (plr) |
27 | local storage = game.ReplicatedStorage.Hair.BuzzCut 1 DYE |
28 | local char = plr.Character |
30 | if char:FindFirstChild( "Humanoid" ) then |
31 | local folder 2 = char.Head.Hair 2 |
35 | local head = char.Head |
36 | local New_Hair = storage:Clone() |
37 | New_Hair.Parent = folder 2 |
38 | New_Hair.Name = "BuzzCutU1DYE" |
39 | New_Hair.Position = head.Position |
40 | local weld = Instance.new( "Weld" ) |
41 | weld.Parent = New_Hair |
42 | weld.Part 0 ,weld.Part 1 = head,New_Hair |
43 | weld.C 0 = CFrame.new( 0 , 0.85 , 0 ) |
44 | weld.C 1 = head.HairAttachment.CFrame |
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