Roblox 中错误 "Infinite yield possible on 'ReplicatedStorage:WaitForChild("Animations")'" 是什么意思?

local RS = game:GetService("ReplicatedStorage")
local Event = Instance.new("RemoteEvent", RS)
Event.Name = "PunchEvent"

local function FiredEvent(Player)
    local Character = game.Workspace:WaitForChild(Player.Name)
    local Animation = RS:WaitForChild("Animations"):GetChildren()[math.random(1, #RS.Animations:GetChildren())]
    print(Animation)
    local RandomAnim = Character.Humanoid:LoadAnimation(Animation)
    RandomAnim:Play()
    local Damage = script.Damage:Clone()
    if Animation.Name == "Right Arm" then
        Damage.Parent = Character:WaitForChild("Right Arm")
    end
    Damage.Disabled = false
    wait(1.4)
    Damage:Destroy()
end

Event.OnServerEvent:Connect(FiredEvent)

这里的图片是可点击的

enter image description here

点赞
用户6115127
用户6115127

第一个输出的错误可能不应该忽略,听起来好像动画资源应该从某个远程地方加载,但是却找不到。

一旦您解决了那个错误,如果超时问题仍没有得到解决,请转到“资源管理器”面板,并确保存在“Animations”子对象。您所提出的错误意味着它在层次结构中找不到该对象。因此,请确保资源管理器中的ReplicatedStorage下有Animations。

2018-03-19 18:42:41
用户8076767
用户8076767

在编程中,“yield”意味着停止,或者在您的情况下,等待。如果您查看输出,第一个错误表明动画加载失败。由于您的代码等待动画加载,因此您会收到警告,您的代码可能会(并且很可能会)永远或无限期地等待动画加载。

2018-03-21 09:53:17