room = script.Parent.Parent.Parent while wait(0.1) do if room.Human:FindFirstChildOfClass("Model") then script.Parent.Humanoid.LeftArm.BrickColor = BrickColor.new("Crimson") print("Arm") else script.Parent.Humanoid.LeftArm.BrickColor = BrickColor.new("Medium stone grey") print("No arm") end end
In this state the script works but after changing this:
if room.Human:FindFirstChildOfClass("Model") then
to this:
if room.Human:FindFirstChildOfClass("Model").Part["Left Arm"] then
it stops working and gives an error [indexing nil value]. How can I make it work? I tried multiple indexing ways but none worked.
I want to index a body part of a humanoid model that has randomly generated name. Script checks if the humanoid has body parts and colours them [red] on a hud if they are present and [grey] if they are gone.
GetDescendants or GetChildren with a For Loop will work, within the for loop you can use if v:IsA("Model") then
to find the children or descendants which are a model or to check the name you can use if v.Name == "Name"
v is an example value used in the for loop for _,v in pairs