not sure if this is how you have your scripts but.
In your Module script:
local Divisions = {
{
Name = "First Order",
GroupId = 39596
},
{
Name = "Roblox Wiki",
GroupId = 127081
},
MainGroup = 39596;
}
function Divisions:GetGroupByName(Name)
for i=1,#self do
local Group = string.lower(self[i].Name) == string.lower(Name)
if(Group == true) then
return self[i]
end
end
warn("Warning: Group Name of "..Name.." Not Found!")
return nil
end
function Divisions:GetGroupById(id)
for i=1,#self do
local Group = self[i].GroupId == id
if(Group == true) then
return self[i]
end
end
warn("Warning: Group Id with "..id.." Not Found!")
return nil
end
return Divisions
And for your Local script:
local MorphsDir = workspace.MorphsDir
local Player = game.Players.LocalPlayer
local Divisions = require(game:GetService("ReplicatedStorage")["Divisions Module"])
local Groups = {"First Order","Roblox Wiki"}
local isAllowedin = {}
for j=1,#Groups do
local Group = Divisions:GetGroupByName(Groups[j])
for i,v3 in pairs (MorphsDir[Group.Name]:GetChildren()) do
local Allowed = false
if v3.Name == "Rank" then
if Player:GetRankInGroup(Group.GroupId) >= v3.Value then
Allowed = true
else
Allowed = false
end
end
if(Allowed == true) then
isAllowedin[#isAllowedin+1] = Group.Name
end
end
end
print("Player Named [",Player.Name,"] is allowed in ...")
for k,v in pairs(isAllowedin) do
print("\t ",v)
end
Non DisplayTable Example:
local MorphsDir = workspace.MorphsDir
local Player = game.Players.LocalPlayer
local Divisions = require(game:GetService("ReplicatedStorage")["Divisions Module"])
local Group = Divisions:GetGroupByName("First Order")
if(Group == nil) then error("Warning:Group is nil!") end
for i,v3 in pairs (MorphsDir[Group.Name]:GetChildren()) do
local Allowed = false
if v3.Name == "Rank" then
if Player:GetRankInGroup(Group.GroupId) >= v3.Value then
Allowed = true
else
Allowed = false
end
end
print(Group.Name," = ",(Allowed == true and "Is" or "Not") .. " Allowed")
end
Link to download my working example here: (7z File link deletes in 2 days!)
http://www.fileconvoy.com/dfl.php?id=gaf547c2824471e4e1000335551932e11c9ecc2a4d5
Hope this helps in some way. You may need to change a few things to get it working.
Let me know if you need more info
2 comments
Is this script part of a bigger script? and are you require'ing the Module script from the ReplicatedStorage folder?, Ill see what i can come up with
The top one is the script its in a folder called "Libs" in replicated storage the middle one is the error the lower one is a part of a bigger script