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
game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect (function(char) local folder = Instance.new("Folder") folder.Parent = char.Head folder.Name = "Hair" end) end) --2nd Folder game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect (function(char) local folder2 = Instance.new("Folder") folder2.Parent = char.Head folder2.Name = "Hair2" end) end) 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
if char:FindFirstChild("Humanoid") then local folder = char.Head.Hair folder:ClearAllChildren() local head = char.Head local New_Hair = storage:Clone() New_Hair.Parent = folder New_Hair.Position = head.Position local weld = Instance.new("Weld") weld.Parent = New_Hair weld.Part0,weld.Part1 = head,New_Hair weld.C0 = CFrame.new(0,0.6,0) weld.C1 = head.HairAttachment.CFrame end
end)
--EmoHair1!Dye game.ReplicatedStorage.HairEvents.HairEvent2.OnServerEvent:Connect(function(plr) local storage = game.ReplicatedStorage.Hair.EmoHair1DYE local char = plr.Character
if char:FindFirstChild("Humanoid") then local folder = char.Head.Hair folder:ClearAllChildren() local head = char.Head local New_Hair = storage:Clone() New_Hair.Parent = folder New_Hair.Position = head.Position local weld = Instance.new("Weld") weld.Parent = New_Hair weld.Part0,weld.Part1 = head,New_Hair weld.C0 = CFrame.new(0,0.6,0) weld.C1 = head.HairAttachment.CFrame end
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
--BuzzCut1 game.ReplicatedStorage.HairEvents.HairEvent3.OnServerEvent:Connect(function(plr) local storage = game.ReplicatedStorage.Hair.BuzzCut1 local char = plr.Character if char:FindFirstChild("Humanoid") then local folder2 = char.Head.Hair2 folder2:ClearAllChildren() local head = char.Head local New_Hair = storage:Clone() New_Hair.Parent = folder2 New_Hair.Name = "BuzzCutU1" New_Hair.Position = head.Position local weld = Instance.new("Weld") weld.Parent = New_Hair weld.Part0,weld.Part1 = head,New_Hair weld.C0 = CFrame.new(0,0.85,0) weld.C1 = head.HairAttachment.CFrame end end) --BuzzCut2 game.ReplicatedStorage.HairEvents.HairEvent4.OnServerEvent:Connect(function(plr) local storage = game.ReplicatedStorage.Hair.BuzzCut1DYE local char = plr.Character if char:FindFirstChild("Humanoid") then local folder2 = char.Head.Hair2 local head = char.Head local New_Hair = storage:Clone() New_Hair.Parent = folder2 New_Hair.Name = "BuzzCutU1DYE" New_Hair.Position = head.Position local weld = Instance.new("Weld") weld.Parent = New_Hair weld.Part0,weld.Part1 = head,New_Hair weld.C0 = CFrame.new(0,0.85,0) weld.C1 = head.HairAttachment.CFrame end end)
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