✓ Accepted answer
local player = game.Players.LocalPlayer
local character = player.CharacterAdded:wait()
for i, v in next, character:GetChildren() do
if v:IsA("Hat") then
if v:FindFirstChild("Handle") then
print("There is the handle")
end
end
end
I'll explain all the code here :
local player is for defining a variable. Here we defined the local player.
local character is for defining a variable. Here we defined when the character is added in the local player.
for i, v in next, character:GetChildren() do. Here we opened a loop with for. i is the index. v is the childs in the variable character.
:GetChildren() is for taking all thing in the variable character.
if v:IsA("Hat") then Here we open a condition if in the character there is a class named "Hat" then.
if v:FindFirstChild("Handle") then Here we open another condition if in the v, there is a part named "Handle" then.
print("There is the handle") is for printing in the output
sorry for my bad english o-o
I hope its will help you!
1 comment
Hats are not loaded as soon as the character is, consider using a wait of about 2 to give the character some time to load it's hats.