Need help with script error

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? For the proximity prompt to clone and parent to the hitbox.

  2. What is the issue? There is an inescapable error. Please refer to the output, please.

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Well, yes, kind of…

Script (Module):
Module

Script (Server):
ServerScript

Output:
image

Thanks for reading this post! Any help is greatly appreciated! :smiley:

Try this for your SetUpTheEgg function?

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
1 Like

Okay! I will try it out! Thank you! :smiley:

It gave me the same error, unfortunately.

It says that the error is from the script in Server Script Service. The script is above.

My bad

Try it again, I think I forgot to reference the Hitbox

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

It is fine, although, I did reference it for you.

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

Okie! I will try it. Thank you!


No proximity prompt. Same output.
image

Are there any proximity prompts under your module?

Yep! Here it is! image

Try printing out the egg’s name before the function and send the output. It may be the egg’s name that’s the problem

Okie! I will try it out! Thank you!

Same error. ;-; image

Your error is happening on Line 7 in your script.

local p = moduleee.SetUpTheEgg(egg.Name)

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.

1 Like

Ok seems like the name is the problem. Do you have a name set for the egg? or do the eggs even exist? Also try SoyPinleon’s solution.

It kind of fixed the problem! image

image
Here are the eggs. Inside of them are hitboxes.
image

Would you mind showing your scripts please?