PlayerSpawns not loading in, resulting in a warning

Hi, for some reason, the player spawns aren’t loading sometimes resulting in a warning. How can i fix this? Here’s my code:

local ContentProvider = game:GetService("ContentProvider")
		for i, children in pairs(clonedMap:GetChildren()) do 
			pcall(function()
				ContentProvider:PreloadAsync({children})
				wait()
			end)
		end
		wait(2)
		if clonedMap:FindFirstChild("PlayerSpawns") then
			round.TeleportPlayers(innocentPlayers, clonedMap.PlayerSpawns:GetChildren())
			round.TeleportSheriff(chosenSheriffPlayer, clonedMap.PlayerSpawns:GetChildren())
			round.TeleportMurderer(chosenMurdererPlayer, clonedMap.PlayerSpawns:GetChildren())
		else
			warn("Fatal Error: no PlayerSpawns Folder")
		end

Update: I added this in:

if clonedMap:FindFirstChild("PlayerSpawns") then
			round.TeleportPlayers(innocentPlayers, clonedMap.PlayerSpawns:GetChildren())
			round.TeleportSheriff(chosenSheriffPlayer, clonedMap.PlayerSpawns:GetChildren())
			round.TeleportMurderer(chosenMurdererPlayer, clonedMap.PlayerSpawns:GetChildren())
		else
			warn("Fatal Error: no PlayerSpawns Folder")
			while true do
				wait(.1)
				if clonedMap:FindFirstChild("PlayerSpawns") then
					round.TeleportPlayers(innocentPlayers, clonedMap.PlayerSpawns:GetChildren())
					round.TeleportSheriff(chosenSheriffPlayer, clonedMap.PlayerSpawns:GetChildren())
					round.TeleportMurderer(chosenMurdererPlayer, clonedMap.PlayerSpawns:GetChildren())
					break
				else
					print("Still not detected")
				end
			end
		end

It’s printing “Still not detected” but it’s never being detected, how do I fix this?

Issue has been fixed, the spawns weren’t anchored apparently. The wonders of programming, let me tell you!

1 Like