Attempted to call require with invalid argument(s)

I made a UI to display warnings, and instead of making seperate UIs, i’m only using one.
I can acheive this by only changing what is written on the UI’s textlabel, So I made a modulescript to make that easier.

However, the modulescript refuses to co-operate by simply warning in output Attemplted to call require with invalid argument(s). I have no clue why, or how.

the modulescript’s code:

local WarningUI = {}
function WarningUI.Warn(warningMessage)
	script.Parent.TextLabel.Text = tostring(warningMessage)
	script.Parent.Visible = true
	script.Parent.Visible = false
return WarningUI

the thing requiring the modulescript’s code:

require(modulescriptpath).Warn("Example Error.")

please help me
thanks so much devforum

There is probably something wrong with the module script path. The error itself is stating that the argument within require() is invalid, which means whatever is in the set of parenthesis is somehow unable to be read by the script properly.

so you’re saying that I required something that somehow doesnt exist even thought it visibly exists

Is this a LocalScript or a Script? What is the path to the ModuleScript?

1 Like

It probably exists, but the script might not realize it exists, either due to the client/server boundary or possibly something isn’t loading in fast enough.

1 Like

Upon playtesting, I have discovered that this works. Something is likely loading faster than it should.
Thanks for your help though!

1 Like

Just add WaitForChild() commands to properly wait for instances referenced in the script.

1 Like