Hello,
I want to be able to give people uniforms based on their rank in their division when clicking a button called “Spawn”, but I’m running into the following problem. The Rank value is included as NumberValue.
Besides that, I also have a simple module with the divisions.
The script attempts to index nil with “IsInGroup”
I’ve changed to code to several different things, but to no avail.
Advice on how to fix this is very much appreciated!
Code:
--Variables
local MorphsDir = game.ReplicatedStorage.Morphs
local Libs = game.ReplicatedStorage.Libs
local Divisions = require(Libs.Divisions)
local Player = game.Players.LocalPlayer
for i = 1,#Divisions do
if Player:IsInGroup(Divisions[i].GroupId) or Divisions[i].GroupId == 0 then
--code
Button.MouseButton1Click:Connect(function ()
for i,v2 in pairs(UniformsFrame:GetChildren()) do
if v2.ClassName == "TextButton" then
v2:Destroy()
end
end
for i,v3 in pairs(MorphsDir[Divisions[i].Name]:GetChildren()) do
local Allowed = true
if v3:FindFirstChild("Rank") then
if Player:GetRankInGroup(Divisions[i].GroupId) == Player:GetRankInGroup(Divisions[i].GroupId) then
Allowed = true
else
Allowed = false
end
end
if Allowed then
-- end of used code
Module:
local Divisions = {
{
Name = "Name";
GroupId = #Number;
};
MainGroup = #Number;
}
return Divisions
--GroupId and MainGroupId not included in the example above.