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

Can I put a parameter in a require()?

Asked by 9 years ago

I am trying to use a modular script but I need it to take a parameter when called.

require(game.Workspace.ModScript,"THIS PARAMETER")
or  
require(game.Workspace.ModScript)("THIS PARAMETER")

If this is possible how would I call it on the modular script?

1 answer

Log in to vote
0
Answered by
ImageLabel 1541 Moderation Voter
9 years ago
local function createMessage (message, time)
    local debris = game:GetService('Debris')
    local screen = Instance.new('Message')
    screen.Text = tostring(message)
    screen.Parent = workspace

    debris:AddItem(screen, time)
end

return createMessage;

Server or Client Script

If the module only returns a function, you can call it along with your require like so require(id)(arguments)

require(workspace['path'])('Scripting Helpers', 5)
--[[ would create a message in the workspace 
with the text `ScriptingHelpers`, and will
only display for five seconds as indicated
by the arguments.
]]

source: this

Ad

Answer this question