Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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 comment

1

This means that "BarrageHold (SP)" does not exist inside of "SPRemotes."

1 answer

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.