Infinite Yield Possible At: Workspace:WaitForChild("Map")

  1. What do you want to achieve?

i was making a system that when the map was loaded
a cable/key would spawn on the spawnpart.

everything work when the map.parent(Loop)
hasnt been written yet. but after i made the loop system
the key wouldnt spawn on the spawn part.

  1. What is the issue? Include screenshots / videos if possible!

The error on the dev console says:

Infinite Yield Possible At: Workspace:WaitForChild(“Map”)

or

Map Is Not A Valid Member Of Workspace “Workspace”

  1. What solutions have you tried so far?

I have try rewritting it but it didnt work.

Heres The 2 Scripts:

gameFunc:

local map = game.Workspace.Map
local Breaker = map.Breaker
local switch1 = Breaker.BreakerSwitch0.Light
local switch2 = Breaker.BreakerSwitch1.Light
local beam0 = Breaker.Beam
local beam1 = Breaker.Beam2
local tool0 = game.ServerStorage.Cable
local tool1 = game.ServerStorage.Cable1

local MainDoor = map.MainDoor
local Door = MainDoor.ScriptedComponents.Door
local DoorButton = MainDoor.ScriptedComponents.Button
local doorDest = MainDoor.ScriptedComponents.DoorDest
local spawns = map.Spawns:GetChildren()

local event = game.ReplicatedStorage.Gui
local OpenSound = Door.Parent.Parent:WaitForChild("sound")

local prox1 = switch1.ProximityPrompt
local prox2 = switch2.ProximityPrompt
local doorProx = DoorButton.ProximityPrompt

prox1.Triggered:Connect(function()
	SpawnTool2()
	beam0.Enabled = true 
	task.wait()
	prox1:Destroy()
end)

prox2.Triggered:Connect(function()
	doorProx.Enabled = true
	beam1.Enabled = true
	task.wait()
	prox2:Destroy()
end)

function ButtonClicked(Player)
	OpenSound:Play()
	DoorButton.ProximityPrompt:Destroy()
	for i = 0,1,0.0001 do
		task.wait()
		Door.CFrame = Door.CFrame:Lerp(doorDest.CFrame, i)
	end
end

function SpawnTool1()
	local newItem = tool0:Clone()
	local ItemSpawn = spawns[math.random(1,#spawns)]
	
	newItem.Handle.CFrame = ItemSpawn.CFrame
	
	newItem.Parent = workspace
end

function SpawnTool2()
	local newItem = tool1:Clone()
	local ItemSpawn = spawns[math.random(1,#spawns)]

	newItem.Handle.CFrame = ItemSpawn.CFrame

	newItem.Parent = workspace
end

event.OnServerEvent:Connect(function()
	print("a player has escaped")
end)

SpawnTool1()

DoorButton.ProximityPrompt.Triggered:Connect(ButtonClicked)

gameLoop:

local map = game.ServerStorage:WaitForChild("Map")

while true do
	map.Parent = game.Workspace
	wait(30)
	map.Parent = game.ServerStorage
end

here are the images:


1 Like

The code provided does not match the outputs.

I’ll try to get to the solution though.

If you replace

local map = game.ServerStorage:WaitForChild("Map")

with

local map = game.ServerStorage:FindFirstChild("Map") or game.Workspace:FindFirstChild("Map")

does it have any effect?

it works but,
i have another script. its for the proximity prompt to appear when equipped
but it didnt work, maybe i wrote it wrong. can you help?

The error is:

infinite yield possible on ‘Workspace.Map:WaitForChild(“BreakerSwitch0”)’

local tool = script.Parent

local map = game.ServerStorage:FindFirstChild("Map") or game.Workspace:FindFirstChild("Map")
local one = map:WaitForChild("BreakerSwitch0").Light.ProximityPrompt

tool.Equipped:Connect(function()
	one.Enabled = true
end)

tool.Unequipped:Connect(function()
	one.Enabled = false
end)

one.Triggered:Connect(function()
	tool.Enabled = false
	wait()
	tool:Destroy()
end)

Have you made sure the map in both ServerStorage and Workspace have the BreakerSwitch?

thank you i got the breaker part wrong

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.