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

Module code did not return exactly one value?

Asked by 3 years ago
Edited 3 years ago

I'm new to scripting, nothing big. I'm basically trying to make this module work but it continues to return with the same error:   14:19:00.830 Module code did not return exactly one value  -  Studio

I'm just attempting to follow a tutorial, it does mess up a bit and breaks itself but I manage to find the problem and fix it myself. Modules is a whole new area for me and I'm just completely braindead at this point.

Currently I'm insure on how to fix this issue, so here's the current code.

local Triangle do
    local v3 = Vector3.new
    local cf = CFrame.new
    local abs = math.abs
    local cross = v3().Cross
    local dot = v3().Dot
    local clone = game.Clone

    local ref = Instance.new('WedgePart') do
        ref.Color         = Color3.fromRGB(200, 200, 200)
        ref.Material      = Enum.Material.SmoothPlastic
        ref.Reflectance   = 0
        ref.Transparency  = 0
        ref.Name          = ""
        ref.Anchored      = true
        ref.CanCollide    = false
        ref.CFrame        = cf()
        ref.Size          = v3(0.25, 0.25, 0.25)
        ref.BottomSurface = Enum.SurfaceType.Smooth
        ref.TopSurface    = Enum.SurfaceType.Smooth
    end

    local function fromAxes(p, x, y, z)
        return cf(
            p.x, p.y, p.z,
            x.x, y.x, z.x,
            x.y, y.y, z.y,
            x.z, y.z, z.z
        )
    end

    function Triangle(a, b, c, parent, wb, wc, N)
        local ab, ac, bc = b - a, c - a, c - b
        local abl, acl, bcl = ab.magnitude, ac.magnitude, bc.magnitude
        if abl > bcl and abl > acl then
            c, a = a, c
        elseif acl > bcl and acl > abl then
            a, b = b, a
        end
        ab, ac, bc = b - a, c - a, c - b
        local out = cross(ac, ab).unit
        wb = wb or clone(ref)
        wc = wc or clone(ref)
        local biDir = cross(bc, out).unit
        local biLen = abs(dot(ab, biDir))
        local norm = bc.magnitude
        wb.Size = v3(0, abs(dot(ab, bc))/norm, biLen)
        wc.Size = v3(0, biLen, abs(dot(ac, bc))/norm)
        bc = -bc.unit
        wb.CFrame = fromAxes((a + b)/2, -out, bc, -biDir)
        wc.CFrame = fromAxes((a + c)/2, -out, biDir, bc)
        local G = Instance.new("Model", parent)
        G.Name = "Floor" .. N
        wb.Parent = G
        wc.Parent = G
        return wb, wc
    end
end

Answer this question