Currently, I'm trying to make a script that changes the leaderboard to add in allies/enemies, but for some reason it isn't working. The outcome of the problem is the string not being created but whenever I remove the following part, it is. I've narrowed the problem down to the GroupService functions but I have no idea why it's not functioning correctly.
For some reason, when the following GroupService part of the script is implemented, it causes a failure in calling a function. Whenever I remove it, the function is called normally. Here's the GroupService parts of the script:
AllyList = game:GetService("GroupService"):GetAlliesAsync(xxxxxxx)
EnemyList = game:GetService("GroupService"):GetEnemiesAsync(xxxxxxx)
Allies = {}
Enemies = {}
for i, v in pairs(AllyList:GetCurrentPage()) do
table.insert(Allies, v.Id)
if not AllyList.IsFinished then
AllyList:AdvanceToNextPageAsync()
end
end
for i, v in pairs(EnemyList:GetCurrentPage()) do
table.insert(Enemies, v.Id)
if not EnemyList.IsFinished then
EnemyList:AdvanceToNextPageAsync()
end
end
Here's the function that is failing to be called (this is after the table insert script by the way and is properly connected to a new player joining):
function CheckRanks(newPlayer)
newPlayer:WaitForChild("leaderstats")
local stats = newPlayer:findFirstChild("leaderstats")
local ranks = Instance.new("StringValue")
ranks.Name = "Ranks"
ranks.Parent = stats
if SecurityMode == "None" then
if CheckIfSpy(newPlayer) then
ranks.Value = "xxx"
end
if ranks.Value ~= nil then
for i, v in pairs(Allies) do
if newPlayer:IsInGroup(v) then
if ranks.Value ~= nil then
ranks.Value = "Ally"
end
end
end
end
if ranks.Value ~= nil then
for i, v in pairs(Enemies) do
if newPlayer:IsInGroup(v) then
if ranks.Value ~= nil then
ranks.Value = "Adversary"
end
end
end
end
elseif SecurityMode == "Lax" then
if CheckIfSpy(newPlayer) then
ranks.Value = "xxxxxxxxxxxxxxxx" .. newPlayer:GetRoleInGroup(xxxxxxx)
elseif newPlayer:IsInGroup(xxxxxxx) then
ranks.Value = "xxxxxxxxxxxxxxxx" .. newPlayer:GetRoleInGroup(xxxxxxx)
elseif newPlayer:IsInGroup(xxxxxxx) then
ranks.Value = "xxxxxxxxxxxxxxxxxxxxxxx " .. newPlayer:GetRoleInGroup(xxxxxxx)
elseif newPlayer:IsInGroup(xxxxxxx) then
ranks.Value = "xxxxxxxxxxxxxxxxxxxxxxx" .. newPlayer:GetRoleInGroup(xxxxxxx)
end
elseif SecurityMode == "Strict" then
if CheckIfSpy(newPlayer) then
ranks.Value = "xxxxxxxxxxxxxxxx" .. newPlayer:GetRoleInGroup(xxxxxxx)
elseif newPlayer:IsInGroup(xxxxxxx) then
ranks.Value = "xxxxxxxxxxxxxxxxxxxxxxx" .. newPlayer:GetRoleInGroup(xxxxxxx)
elseif newPlayer:IsInGroup(xxxxxxx) then
ranks.Value = "xxxxxxxxxxxxxxxxxxxxxxx" .. newPlayer:GetRoleInGroup(xxxxxxx)
elseif newPlayer:IsInGroup(xxxxxxx) then
ranks.Value = "xxxxxxxxxxxxxxxx " .. newPlayer:GetRoleInGroup(xxxxxxx)
end
end
ranks.Value = "Visitor/Floater"
end
game.Players.PlayerAdded:connect(CheckRanks)
EDIT #1: Fixed the table insert from v.groupId to v.Id and it is now returning the actual values instead of nil but the problem still arises. I added new information that is crucial to my problem.
Note: I have a valid groupID in place of the x's. I just don't want to be stalked.

1 comment
Sorry, I haven't used this site for a while so I forgot how much detail about my problem that I should've added in. The outcome isn't an error groupService itself but whenever I remove the groupService code, it fixes the outcome. I've updated the OP to give more information. Thanks though for helping, maybe with this new information it fixes it?