Today I made a ModuleScript called “CreateScript” and what it does is creates a script if you use the correct use of the parameters and stuff. I tried requiring the script but then I got the following error.
It always errors when I try to require and I have no Idea what is wrong.
My CreateScript code in my module.
local function CreateScript(Script,Name,Source,Parent)
if Script.ClassName == “Script” then
Script.Name = Name
Script.Source = Source
Script.Parent = Parent
elseif Script.ClassName == “LocalScript” then
Script.Name = Name
Script.Source = Source
Script.Parent = Parent
elseif Script.ClassName == “ModuleScript” then
Script.Name = Name
Script.Source = Source
Script.Parent = Parent
else
warn(“The Script/Object your trying to insert cannot be created with Instance.new function.”)
end
I think you should try making your function like this.
local module = {}
module.CreateScript = function(Script,Name,Source,Parent)
if Script.ClassName == “Script” then
Script.Name = Name
Script.Source = Source
Script.Parent = Parent
elseif Script.ClassName == “LocalScript” then
Script.Name = Name
Script.Source = Source
Script.Parent = Parent
elseif Script.ClassName == “ModuleScript” then
Script.Name = Name
Script.Source = Source
Script.Parent = Parent
else
warn(“The Script/Object your trying to insert cannot be created with Instance.new function.”)
end
end
return module
When calling it do
local module = require(mod)
module.CreateScript(parem1, parem2, etc)
OR you are using a local function, I am not completely sure but try what I did above.
I withdrew my post because i didnt realize you were requiring it from the command bar. I can really only suggest making the function “function module.CreateScript()”