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

Why is this function printing "Invalid parameter" when the parameter I give is a boolean?

I was trying to make a module script that I could use to control an intermission text bar.

This code is intended to change the visibility of the text bar:

function module.visible(bool)
	local intermissionGUI = script.Parent
	local intermissionText = intermissionGUI:WaitForChild("TextLabel")
	
	if bool == true then
		intermissionText.Visible = true
	elseif bool == false then
		intermissionText.Visibile = false
	else
		warn("Invalid parameter!")
	end
end

I tried running the visible() function using the following script:

local gui = require(game.ServerStorage:WaitForChild("InterGUI"))

gui:visible(false)

But the ModuleScript just prints out "Invalid parameter!"

Any help will be appreciated!

2 comments

0

Try gui.visible(false)

0

Try gui.visible(false)

1 answer

✓ Accepted answer

the problem is how your calling the function, when you define a function as module.method() and call the function via module:method, the first argument passed to the method is the object (module).. so just do module.visible(true), or otherwise define the method with the colon operator -> module:visible()

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