I already have the character defined, but i'm not quite sure how to find the hats. I plan for the hats to turn invisible, for another script I was making.
local Player = Game.Players.LocalPlayer local Char = Player.CharacterAdded:wait() local Hats = Char:getChildren() for i = 1,#Hats do if Hats[i].ClassName == "Hat" then hat = Hats[i]:FindFirstChild("Handle") hat.Transparency = 1 end end
I'm not sure why it's not working. No errors in output.
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!