Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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!

0
Try `gui.visible(false)` Leamir 3138 — 4y
0
Try `gui.visible(false)` Leamir 3138 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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()

Ad

Answer this question