As of right now, I am having an issue with making handles inside of a hat transparent and I don’t know why.
I use a for,loop to basically get all the hats, then another for,loop to get all the parts named “Handle”, but it doesn’t work.
Here is the script:
for _, hats in pairs(character:GetChildren()) do
if hats:IsA("Hat") and hats ~= nil then
for hats, handles in pairs(hats:GetChildren()) do
if handles:IsA("Part") and handles.Name == "Handle" then
handles.Transparency = 1
end
end
end
end
I am using this inside of a LocalScript located in StarterCharacterScripts, I really need some assistance on this and an explanation on why this is happening.
I was in a rush when I wrote that reply so let me further elaborate! You can first check if the item is an accessory and then use the AccessoryType property to determine what type of accessory it is (Hat, Face, Waist, etc…). Hope this helps!
local storage = game:GetService("ServerStorage")
local players = game:GetService("Players")
local replicated_Store = game:GetService("ReplicatedStorage")
local camera_event = replicated_Store.camera_event
local c_bud = storage:WaitForChild("camera_buddy")
players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
local head = char:WaitForChild("Head")
local c_bud_clone = c_bud:Clone()
c_bud_clone.Parent = char
local motor = Instance.new("Motor6D", char)
motor.C0 = CFrame.new(motor.C0.X,motor.C0.Y,motor.C0.Z) * CFrame.Angles(math.rad(0),math.rad(0),math.rad(0))
motor.Part0 = head
motor.Part1 = c_bud_clone
motor.Name = "camera_motor"
camera_event:FireClient(plr)
for _, v in pairs(char:GetChildren()) do
if v:IsA("Accessory") then
v:Remove()
end
end
return char
end)
end)
This is probably because the accessories are not loaded in when the CharacterAdded event is triggered. To fix this issue you can use the CharacterAppearanceLoaded event instead of CharacterAdded!