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

How do I create a check to see if a level is higher than another..?

Asked by 3 years ago

  1. I'm attempting to create an overhead GUI for a group that has other groups linked to it. (Sub groups would come in real handy right now.)

  2. The issue is when I go to load in-game, I always get a lower ranked group compared to the others.

  3. I genuinely don't know what solution to try, I feel like this was done correctly and I'm just missing a key element to this.


Scripts

Settings Module

local Settings = {}

Settings.Admins = {
    ["Groups"] = {
        ["Vortex Special Ops"] = {
            GroupID = 254932,
            SubGroupsActive = true,
            Active = true,
            RankRequirement = 249,
            SubGroups = {
                ["Highranks"] = {
                    Level = 5,
                    Active = true,
                    SubGroupID = 280826,
                    RankRequirement = 1,
                },
                ["Airborne"] = {
                    Level = 4,
                    Active = true,
                    SubGroupID = 286052,
                    RankRequirement = 1,
                },
                ["Rancor Battalion"] = {
                    Level = 3,
                    Active = true,
                    SubGroupID = 734442,
                    RankRequirement = 100,
                },
                ["Naval Forces"] = {
                    Level = 2,
                    Active = true,
                    SubGroupID = 595668,
                    RankRequirement = 253,
                },
                ["Tags"] = {
                    Level = .1,
                    Active = false,
                    SubGroupID = 595668,
                    RankRequirement = 253,
                },
                ["Investment"] = {
                    Level = .2,
                    Active = false,
                    SubGroupID = 595668,
                    RankRequirement = 253,
                },
                ["Technicians"] = {
                    Level = .3,
                    Active = false,
                    SubGroupID = 595668,
                    RankRequirement = 253,
                },
            }
        }

    }
}



return Settings

Function Module

local Settings = require(script.Parent.Settings)
local GroupService = game:GetService("GroupService")
local Players = game:GetService("Players")
local Protocol = {}

Protocol.Functions = {
    ["Overhead Check"] = {
        Description = "",
        Function = function(plr)
            for i,Group in pairs (Settings.Admins.Groups) do
                if Group.Active then
                    if Group.SubGroupsActive then
                        for index,SubGroup in pairs (Group.SubGroups) do
                            if SubGroup.Active then
                                if plr:GetRankInGroup(SubGroup.SubGroupID) >= 1 and game.Workspace:FindFirstChild(plr.Name) and game.Workspace[plr.Name].Head:FindFirstChild("VSOOverhead") and game.Workspace[plr.Name].Head.VSOOverhead.CurrentLevel < SubGroup.Level then
                                    local groupInfo = GroupService:GetGroupInfoAsync(SubGroup.SubGroupID)
                                    local info2send = {groupInfo.EmblemUrl,plr:GetRoleInGroup(SubGroup.SubGroupID),SubGroup.Level}
                                    return info2send
                                elseif plr:GetRankInGroup(SubGroup.SubGroupID) >= 1 then
                                    local groupInfo = GroupService:GetGroupInfoAsync(SubGroup.SubGroupID)
                                    local info2send = {groupInfo.EmblemUrl,plr:GetRoleInGroup(SubGroup.SubGroupID),SubGroup.Level}
                                    return info2send
                                end
                            end
                        end
                    end
                    if plr:GetRankInGroup(Group.GroupID) >= 1 and game.Workspace:FindFirstChild(plr.Name) then
                        local groupInfo = GroupService:GetGroupInfoAsync(Group.GroupID)
                        local info2send = {groupInfo.EmblemUrl,plr:GetRoleInGroup(Group.GroupID),0}
                        return info2send
                    elseif plr:GetRankInGroup(Group.GroupID) >= 1 then
                        local groupInfo = GroupService:GetGroupInfoAsync(Group.GroupID)
                        local info2send = {groupInfo.EmblemUrl,plr:GetRoleInGroup(Group.GroupID),0}
                        return info2send
                    end
                else
                    return false
                end
            end
        end,
    }
}

return Protocol

Script

local Admin = require(script.Parent.Parent.Modules.Functions)

game.Players.PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        local GroupInfo = Admin.Functions["Overhead Check"].Function(plr)
        if char.Head:FindFirstChild("VSOOverhead") and char.Head.VSOOverhead.CurrentLevel < GroupInfo[3] then
            local GUI = char.Head.VSOOverhead
            GUI.Rank.Text = GroupInfo[2]
            GUI.Icon.Image = GroupInfo[1]
            GUI.CurrentLevel.Value = GroupInfo[3]
        else
            local GUI = script.VSOOverhead:Clone()
            print(GroupInfo)
            GUI.Rank.Text = GroupInfo[2]
            GUI.Icon.Image = GroupInfo[1]
            GUI.CurrentLevel.Value = GroupInfo[3]
            GUI.Parent = char.Head
        end
    end)
end)

Thank you for any assistance you can give me.

Answer this question