Need help with script error

Script:

local rep = game:GetService("ReplicatedStorage")
local moduleee = require(rep:WaitForChild("EggModule_Server"))

wait(5)

for _, egg in pairs, (game.Workspace.Eggs:GetChildren()) do
	local p = moduleee.SetUpTheEgg(egg.Name)
	p.Triggered:Connect(function(plr)
		moduleee.EggHatch(plr, egg.Name)
	end)
end

Module Script:

local plrs = game:GetService("Players")
local repsto = game:GetService("ReplicatedStorage")
local eggs = game.Workspace:WaitForChild("Eggs")


local module = {}

function module.EggHatch(plr, eggName)
	print("o")
end

function module.SetUpTheEgg(eggName)
	local egg = eggs:FindFirstChild(eggName)

	if egg and egg:FindFirstChild("Hitbox") then
		local p = script.ProximityPrompt:Clone()
		p.Parent = egg:FindFirstChild("Hitbox")

		return p
	end
end

return module

Hmm. Try printing eggName and see if it’s nil. That’s all I can say.

I did try to print the name. I think the error is in the script, not the module.

try printing the actual egg itself and the parent.

2c8c4ea647b14b26c014fee185d40450d68f0788
At the bottom of the picture you can see ReplicatedStorage.EggModule_Server which means the error is coming from the module. You can also see EggModule_Server:15. The 15 is the line number the error is on. From what I can tell the error is coming from this specific line if egg and egg:FindFirstChild("Hitbox") then unless you added whitespace lines.

Spammed the output window.

That for loop line looks weird.

for _, egg in pairs, (game.Workspace.Eggs:GetChildren()) do

I think you either do

for _, egg in pairs(game.Workspace.Eggs:GetChildren()) do

or

for _, egg in next, game.Workspace.Eggs:GetChildren() do
1 Like

yeah sorry that was my mistake i forgot to tell you i edited it back without the comma.

1 Like

IT WORKED!!! THANK YOU SO MUCH! Everyone, thank you so much for all the help! I am very grateful for all the help!

2 Likes