Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

What does Infinite yield possible on ReplicatedStorage.remote:WaitForChild("remote") mean?

Asked by 4 years ago
local rp = game:GetService("ReplicatedStorage")
local Barrage = rp:WaitForChild("SPRemotes"):WaitForChild("BarrageHold (SP)")

local active = false
script.Parent.MouseButton1Click:connect(function()
    Barrage:FireServer(active)
end)

Here is my basic code, though once ran it says Infinite yield possible on 'ReplicatedStorage.SPRemotes:WaitForChild("BarrageHold (SP)")'

What does this mean and how can I fix it?

1
This means that "BarrageHold (SP)" does not exist inside of "SPRemotes." lunatic5 409 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

Try this

local function WaitForChild(parent, childName)
    while not parent:FindFirstChild(childName) do parent.ChildAdded:wait() end
    return parent[childName]
end

local rp = game:GetService("ReplicatedStorage")
local SPRemotes = WaitForChild(rp, "SPRemotes")
local Barrage = WaitForChild(SPRemotes, "BarrageHold (SP)")

local active = false

script.Parent.MouseButton1Click:Connect(function()
    Barrage:FireServer(active)
end)

Ad

Answer this question