function SetUpTheEgg(eggName)
local egg = eggs:FindFirstChild(eggName)
if egg and egg:FindFirstChild("Hitbox") then
local p = script.ProximityPrompt:Clone()
p.Parent = egg.Hitbox
return p
end
end
To me it seems like it’s either that there are no eggs in the egg table thus returning nil when trying to call for its name. Or maybe its the in next, that is the problem. I don’t have any experience with in next I usually use in pairs,. Try that, should be setup like this:
for _, egg in pairs (game.Workspace.Eggs:GetChildren()) do
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 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
attempt to call a nil value means attempting to call a function that doesn’t exist.
In your module script you did this:
function SetUpTheEgg(eggName)
--code
end
you didn’t do
function module.SetUpTheEgg(eggName)
--code
end
This should fix your problem. If you don’t put module. at the beginning of the function name then the function will not be a part of the module as it returns the table module and the functions are supposed to be in that table so you can grab it in other scripts.