Egg Gui only shows on one egg?

Hello! I am trying to make a BillboardGui get adorned to any eggs when they are within 10 studs of them. For some reason this only happens to one egg out of the three eggs that should all be working. If it matters the egg that works is random and not one in particular. Any ideas why this isn’t working?

This is my code:

task.wait(2)

local player = game:GetService("Players").LocalPlayer
local playerGui = player.PlayerGui

local char = workspace:WaitForChild(player.Name)
print(char)
print(char:WaitForChild("HumanoidRootPart"))
while wait(0.25) do
	for i, world in pairs(workspace.Worlds:GetChildren()) do
		if world:FindFirstChild("Eggs") then
			for i, eggFolder in pairs(world.Eggs:GetChildren()) do
				if eggFolder:IsA("Folder") and eggFolder.Name == "Plains" then
					for i, egg in pairs(eggFolder:GetChildren()) do
						if egg.Name ~= "WorldName" then
							local magnitude = (egg.Egg.Position - char:WaitForChild("HumanoidRootPart").Position).Magnitude
							print(magnitude)
							print(egg.Name)
							if magnitude <= 10 then
								playerGui.EggGui.Adornee = egg
								playerGui.EggGui.Enabled = true
							else
								playerGui.EggGui.Adornee = nil
								playerGui.EggGui.Enabled = false
							end
						end
					end
				end
			end
		end
	end
end

This is what the explorer looks like:
Screen Shot 2023-06-25 at 5.01.03 PM
All three eggs are structured the same as the Basic egg, and the Eggs folder is in the Plains folder.

Thanks in advance! :slight_smile:

2 Likes