Requested module experienced an error while loading

Hello, i just finished making my egg hatching system everything is working fine i have 2 eggs but when i added the third one the output keeps on saying:
Requested module experienced an error while loading
and also the module is stored on the egg incubator in the workspace.
Here is my script:


local clickdetector = script.Parent.ClickDetector
local cd = false
local cost = script.Parent.Price.Value
local pets = game.ReplicatedStorage.AllPets
local module = require(script.Parent:WaitForChild("ModuleScript"))
clickdetector.MouseClick:Connect(function(player)

if not player:FindFirstChild("CanOpenEgg") then
	local canOpenEgg = Instance.new("BoolValue")
	canOpenEgg.Parent = player
	canOpenEgg.Name = "CanOpenEgg"
	canOpenEgg.Value = true
end
	local pg = player:WaitForChild("PlayerGui")
	local inv = pg.Inventory
	local egg = script.Parent.Parent.ViewportFrame:Clone()
	local pet = script.Parent.Parent.ViewportFrame2:Clone()
	if player.leaderstats.Coins.Value >= cost then
			if player:FindFirstChild("CanOpenEgg").Value == true then
			player:FindFirstChild("CanOpenEgg").Value = false
			player.leaderstats.Coins.Value = player.leaderstats.Coins.Value - cost
			local p = module.randPet()
			p:Clone().Parent = player.Pets
			egg.Parent = inv
			wait(2)
			egg:Destroy()
			pet.Parent = inv
	
		local cam = Instance.new("Camera",script)
			cam.CameraType = Enum.CameraType.Scriptable

			local point = Vector3.new(0,0,0)

			local r = 0

			local item = p:Clone()

			pet.CurrentCamera = cam

			item:SetPrimaryPartCFrame(CFrame.new(point))

			item.Parent = pet
			game.ReplicatedStorage.PLayHatchSound:FireClient(player)
			while true do
			wait()
			local cframe, size = item:GetBoundingBox()
			local max = math.max(size.X,size.Y,size.Z)
			local distance = (max/math.tan(math.rad(cam.FieldOfView))) * 2
			local dis = (max/2) + distance
			cam.CFrame = CFrame.Angles(0,math.rad(r),0) * CFrame.new(point + Vector3.new(0,0,dis), point)
				r = r + 7
				if r >= 183 then
					
					break
				end
			end
			
			wait(1.5)
			pet:Destroy()
			wait(0)
			player:FindFirstChild("CanOpenEgg").Value = true
		end
	end
end)

Thank you!

seems weird, so the ‘local module’(when you define it) returns the error/warn?
if so, try parenting it somewhere else, because, it should work

1 Like

Okay i will try that thank you!

Parenting the model or the script?

Never mind i found the error it was an error on the module.