Infinite yield possible on 'Workspace.Dummies.Dummy.Humanoid:WaitForChild("Animator")'
I get this error for some reason, I’m trying to get everything players and dummies within a certain radius to play an animation.
for i,v in pairs(workspace.Dummies:GetChildren()) do
if (player.Character.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude <= 15 then
table.insert(targets, v)
end
end
I get all the characters in the targets table to play the animation but it seems to only work on players.
Some NPCs may not have the Animator instance. For a failsafe, do this.
for i,v in pairs(workspace.Dummies:GetChildren()) do
if (player.Character.HumanoidRootPart.Position - v.HumanoidRootPart.Position).Magnitude <= 15 then
if not v.Humanoid:FindFirstChildOfClass("Animator") then
local animator = Instance.new("Animator")
animator.Parent = v.Humanoid
end
table.insert(targets, v)
end
end