Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Better way to make a MainModule? How would I go about it, or should I not bother changing it?

My mainmodule:

if workspace:FindFirstChild("Sword Admin v3") then
	return {script; on = true;}
else
	print("Sword Admin is not inserted correctly into this place.")
	return {script; on = true;}
end

So, Is there? People constantly tell me there is but don't further explain it. All help is appreciated!

Note: It's 3am... I'm going to sleep so I'll check on this in the morning!

ALSO, YES, MY CODE DOES WORK!

1 answer

✓ Accepted answer

Yes there is.

assert(workspace:FindFirstChild("Sword Admin v3"),"Sword Admin is not inserted correctly into this place.")
return {script; on = true;}

assert is a function that takes 2 parameters. First one is a bool [a], second is string [b].

If a is false or nil, then assert errors b.

Keep in mind that FindFirstChild returns Instance or nil.

I don't understand why would you want to return script in a modulescript... If assert will error then the function will return nothing.

Additionally, you could try returning the table before calling assert.

Please mark as solved if helped. Thanks!

1 comment

0

I return the script so that when it is required by the loader, it inserts the script. Thanks for helping!

This discussion is preserved as it was. New answers, comments, and votes are closed.