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

Help with ModuleScripts. Two different errors?

Asked by
waifuSZN 123
6 years ago

16:30:51.061 - Module code did not return exactly one value 16:30:51.063 - Requested module experienced an error while loading

Where I require the scripts:

role = require(table.remove(roles, math.random(#roles)))

One of my roles (they are all the same):

local Role = require(game.ServerScriptService.Roles.defRole)()

Role.ID = "Cop";
Role.Ability = "Investigate one player per night.";
Role.Attributes = "Vote for one player at night. The next day you get a hint of the player's role."
Role.Alignment = "town";
Role.Meetings = {"inves", "lynch"};
Role.Items = {}

return Role

The defRole:

return function()
    local Role = {
    ID = "";
    Ability = "";
    Attributes = "";
    Alignment = "";
    Meeting = {};
    Items = {}
    }

    Role.canKill = function(gameObject, target, reason)
        return true
    end

    Role.onKill = function(gameObject, target, reason)
        Role.defaultOnKill(gameObject, target, reason)
    end

    Role.defaultOnKill = function(gameObject, target, reason)
        local char = target.Character
        if char then
            char:BreakJoints()
            wait(5)
            char:Destroy()
        end
    end


    return Role
end

Not sure why this is happening, if anyone has any input I would be highly appreciative.

1 answer

Log in to vote
0
Answered by 6 years ago

If you put the scripts you've provided in a blank place, they do not error.

The first error message occurs when a ModuleScript attempts to return multiple things, like return 1, 2, OR when a ModuleScript doesn't return anything (interestingly, you can return nil, but you cannot just say return). You'll have to inspect the full error for the script and line number where it happens - that'll be the require statement that required the ModuleScript that's at fault.

The second error message, "Requested module experienced an error while loading", always happens when you require from a ModuleScript that errors. Just fix the first one and this one will disappear.

Ad

Answer this question