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

Is there a way to check if a ModuleScript has a certain function?

There is a ModuleScript that will have a function called Name4(). Basically, Name4() returns a string value. Sometimes, the module WILL have Name4, and other times, it WON'T have Name4, because each player has their own version of the module parented to their Characters.

if module.Name4() ~= nil then
	local name = module.Name4() -- Gets name of attack from module
	script.Parent.Text = name
	script.Parent.Visible = true
end

I want lines 2-4 to take place if the ModuleScript DOES have Name4(). But I'm unable to use this if statement to check if whether the module has Name4 or not. Any thoughts?

1 comment

0

Maybe switch module.Name4() ~= nil with module.Name4() ~= ""

1 answer

local module = require(~module directory~)

if module.FunctionName then
	module.FunctionName(~parameters~)
end

3 comments

0

Thank you so much man

0

accept answer!

0

accept answer!

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