从 moduleScript 中拉取 GroupId

Pulling GroupId from moduleScript

提问人:hard R 提问时间:11/11/2023 最后编辑:hard R 更新时间:11/11/2023 访问量:14

问:

我正在开发 Roblox 开销 GUI,并且正在使用 moduleScript 作为值。它目前提取其喜欢的随机值,而不是遵守参数。

脚本的(相关)部分执行:

local userRankInGroup = plr:GetRankInGroup(32494019)
        
        for _, division in pairs(config) do
            local groupIdToCheck = division["Group Id"]
            if userRankInGroup and userRankInGroup >= division["Minimum RankId"] and userRankInGroup <= division["Maximum RankId"] then
                clonedUI.DivRank.Text = division["Regiment Name"]
                clonedUI.DivRankShadow.Text = division["Regiment Name"]
                clonedUI.regimentFrame.regimentIcon.Image = division["Image Id"]
                clonedUI.regimentFrame.BackgroundColor3 = division["Regiment Color"]
                print("Overhead GUI for".. plr .."has loaded successfully.")
                break
                else 
            end
        end 

moduleScript:

local regiments = {
    
    
    ["Office of The Inspector General"] = {
        ["Regiment Name"] = "OIG",
        ["Group Id"] = 32921091,
        ["Image Id"] = "http://www.roblox.com/asset/?id=14412072617",
        ["Regiment Color"] = Color3.new(0.435294, 0.372549, 0.0117647),
        ["Minimum RankId"] = 5,
        ["Maximum RankId"] = 250,
        
    },
    
    
    ["Naval Special Warfare Command"] = {
        ["Regiment Name"] = "NSWC",
        ["Group Id"] = 32954415,
        ["Image Id"] = "http://www.roblox.com/asset/?id=15186922222",
        ["Regiment Color"] = Color3.new(0.129412, 0.129412, 0.129412),
        ["Minimum RankId"] = 5,
        ["Maximum RankId"] = 250,

    },

        }
        
    
return regiments

我试着拉下来,因为我认为这就是问题所在。但后来它只是没有返回任何值,只是给了我空白选项。local userRankInGroup = plr:GetRankInGroup(32494019)if userRankInGroup and userRankInGroup >= division["Minimum RankId"] and userRankInGroup <= division["Maximum RankId"] then

Lua Roblox Lua-Table

评论

0赞 UnholySheep 11/11/2023
您是否尝试过使用代替?此外,你的两个“团”都有完全相同的最小和最大 rankId,所以我不确定你实际上认为哪个结果是正确的ipairspairs
0赞 hard R 11/13/2023
切换到并没有真正的帮助。相反,它没有提取任何数据,因此它显示默认 GUI。至于 ID,它们彼此之间并不真正相关,因为 ID 不同。ipairs

答: 暂无答案