I’m writing plugin code in a VSCode and Argon environment. I’m encountering an error when trying to load a ModuleScript from the plugin code. Could someone please explain the correct way to load it?
Here’s the specific code I’m using:
init.server.luau
local ColorModule = require(colorModule)
local toolbar = plugin:CreateToolbar("Color Changer")
local button = toolbar:CreateButton(
"Change Color",
"Randomly change color of selected objects",
"rbxassetid://4458901886"
)
local function changeColor()
local selection = game:GetService("Selection")
local selectedObjects = selection:Get()
for _, object in ipairs(selectedObjects) do
ColorModule.changeObjectColor(object)
end
end
button.Click:Connect(changeColor)
colorModule.server.luau
local ColorModule = {}
function ColorModule.getRandomColor()
return Color3.new(math.random(), math.random(), math.random())
end
function ColorModule.changeObjectColor(object)
if object:IsA("BasePart") then
object.Color = ColorModule.getRandomColor()
end
end
return ColorModule
Any help would be greatly appreciated. Thanks in advance!