Can't index a dictionary

  1. What do you want to achieve? Keep it simple and clear!

I want to retrieve the player’s groups using GroupService, then index through the result to find a specific group ID. If the group ID is found, I want to retrieve their rank from that group.

  1. What is the issue? Include screenshots / videos if possible!

The issue is that my script can’t index the specific group ID I’m looking for. The if-then statement returns false, and my else statement fires for all the groups (including my specific group).

** CODE **

staffFunction.OnServerInvoke = function(player, id)
	local groups = GroupService:GetGroupsAsync(id)
	
	for _, group in groups do
		print(group)
		if group.EmblemId == 6878947 then
			print("I FOUND THE GROUP")
		else
			warn("Group does not exist")
		end
	end
end

IMAGES

Don’t you mean the Id? The EmblemId is meant to be used for the thumbnail within the EmblemUrl link, so you should be referencing that cause there’s the possibly that some other EmblemId's could also have the same Image asset as well

staffFunction.OnServerInvoke = function(player, id)
	local groups = GroupService:GetGroupsAsync(id)
	
	for _, group in groups do
		print(group)
		if group.Id == 6878947 then
			print("I FOUND THE GROUP")
		else
			warn("Group does not exist")
		end
	end
end
2 Likes

You’re right, my bad lmao. Thank you!

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.