ServerScriptService error, but where?

Heya! I’m K0rrupt! Also known as “xt12t” and “K0rruqt”!

I am currently making a game similar to Piggy, but while testing in a Local Server, there was this error in the output, and I can’t really see where the error is. All feedback will be appreciated!

Error:

There is an error on the script or module script named “RoundModule”. His parent is “Game Logic” which is inside ServerScriptService.

Note: The error is with piggy which seems to be nil

1 Like

So what do I have to do to fix it?

Since piggy is nil, add this as the first line in the DressPiggy event

assert(piggy ~= nil, "Piggy is nil, do not continue function")

when you’re calling the function module.DressPiggy() you arent passing the parameter so it becomes nil

1 Like

When referencing objects inside of Server Storage, you want to use :FindFirstChild() or :WaitForChild(), otherwise your code may error.

In this case, a possible cause for error may be that you are trying to find “Piggy” inside server storage before it is available or it could be the wrong name.

So use something like

local piggyLocation = game:GetService("ServerStorage"):WaitForChild("Piggy") --outside the function, so it does not search for this object everytime

local character = piggyLocation:Clone() --inside the function, since it is a clone

Make sure the piggy argument has a property named Name.

What do you mean by “passing a parameter”??

function foo(param)
    print(param)
end
foo("Hello World!") -- this is passing a parameter
foo() -- this is not
1 Like