Is it possible to use FindFirstChild(Instance) instead of FindFirstChild(“Name”). I want to specify which Part it is because it has the same name as other parts in the parent.
You can use :FindFirstChildWhichIsA() which checks if the child is a part, humanoid, model, etc.
script.Parent.Touched:Connect(function(OtherPart) local EnemyHumanoid = OtherPart.Parent:FindFirstChildWhichIsA("Humanoid") if EnemyHumanoid then EnemyHumanoid:TakeDamage(10) end end)
If you cannot get the child in the first place through its name, then it is not possible to reference it unless you determine what it is through your own conditions.
for i, v in parts:GetChildren() do if v:IsA("BasePart") and v.Size == Vector3.one then --do code, where 'v' is the part break --break the loop once finished, because that one was the correct part. end end
The code above will determine if the part has a size of 1, 1, 1. This way, you can determine what kind of instance you want depending on its properties regardless of name.