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

A really weird Module error not sure what it is?

Asked by 7 years ago

I'm not sure why this isnt working! I did get this error tho,

22:33:31.904 - Requested module experienced an error while loading

Server Script:


local Make = require(script.MakeBrick) Make("AmazingPart", BrickColor.new('Lime green'), Enum.Material.Neon, game.Workspace)

Module Script:

function MakeBrick(Name, Color, Material, Parent)
local Part = Instance.new('Part', Parent)
Part.Name = Name
Part.BrickColor = Color
Part.Material = Material
Part.Anchored = true
Part.CFrame = game.Workspace.SpawnLocation.CFrame
end

return MakeBrick()

1 answer

Log in to vote
0
Answered by
BlueTaslem 18071 Moderation Voter Administrator Community Moderator Super Administrator
7 years ago
Edited 7 years ago

Read your output. It says that the "request module experienced an error while loading".

What is that error? It says

09:14:06.321 - ServerScriptService.Script.MakeBrick:3: bad argument #3 to 'Name' (string expected, got nil)

09:14:06.323 - Stack Begin

09:14:06.324 - Script 'ServerScriptService.Script.MakeBrick', Line 3 - global MakeBrick

09:14:06.324 - Script 'ServerScriptService.Script.MakeBrick', Line 10

09:14:06.324 - Stack End

Why is the modulescript calling MakeBrick on line 10?

return MakeBrick()

That's clearly not right. MakeBrick doesn't return anything, so this can't be correct.


You want the ModuleScript to give other people the function itself, so you can't call it for them.

The last line of the ModuleScript should be modified to be

return MakeBrick
-- without parentheses!
Ad

Answer this question