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

1 event works but the other 2 doesn't??

Asked by 6 years ago

well you see, i am designing hat customization where u click on a gui it gives u a hat and stuff and if u click a different gui it removes your hat and puts on a new one, and it works fine, but 2 hats dont fit on the head, and it does not change the parent to the character, only 1 hat fits perfectly on the character because it is ACTUALLY in the character

--// Client
local Player = game.Players.LocalPlayer

local Character = Player.Character
--// Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")

--// Objects
local BHFBP = ReplicatedStorage:WaitForChild("Ultra-Fabulous Hair Black")
--[[local BlondHair = ReplicatedStorage:WaitForChild("Ultra-Fabulous Hair Blond")
local BrownHair = ReplicatedStorage:WaitForChild("Ultra-Fabulous Hair Brown")--]]
local BlackAndRedHair = ReplicatedStorage:WaitForChild("Black and Red")
local Shaggy = ReplicatedStorage:WaitForChild("Shaggy")
local HatStorage = workspace.TestHatFolder

--// Guis
local MainGui = script.Parent
    local BlackAndRedGui = MainGui:WaitForChild("Red and Black")
    local BHFBPGui = MainGui:WaitForChild("Beautiful Hair for Beautiful People")
    local ShaggyGui = MainGui:WaitForChild("Shaggy")

--// Main
BlackAndRedGui.MouseButton1Down:Connect(function()
    HatStorage:ClearAllChildren()
    local NewHair =  BlackAndRedHair:Clone()
    NewHair.Parent = HatStorage
    NewHair.Handle.CFrame = Character:WaitForChild("Head").CFrame
    local Hats = Character:GetChildren()
    for i = 1, #Hats do
        if (Hats[i].ClassName == "Accessory") then
            Hats[i]:Remove()
        end
    end 
end)

--Working
BHFBPGui.MouseButton1Down:Connect(function()
    HatStorage:ClearAllChildren()
    local NewHair = BHFBP:Clone()
    NewHair.Parent = HatStorage
    NewHair.Handle.CFrame = Character:WaitForChild("Head").CFrame

    local Hats = Character:GetChildren()
    for i = 1, #Hats do
        if (Hats[i].ClassName == "Accessory") then
            Hats[i]:Remove()
        end
    end 
end)


ShaggyGui.MouseButton1Down:Connect(function()
    HatStorage:ClearAllChildren()
    local NewHair = Shaggy:Clone()
    NewHair.Parent = HatStorage
    NewHair.Handle.CFrame = Character:WaitForChild("Head").CFrame

    local Hats = Character:GetChildren()
    for i = 1, #Hats do
        if (Hats[i].ClassName == "Accessory") then
            Hats[i]:Remove()
        end
    end 
end)

0
Use welds and see the C0 and C1 properties of welds. hiimgoodpack 2009 — 6y

Answer this question