Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Is it possible to run Player:GetRankInGroup without an if at the beginning?

So I'm fixing my whitelist and here's my code so far:

game.Players.PlayerAdded:connect(function(p)
	if game.CreatorType == Enum.CreatorType.Group then
	Group = game.CreatorId
		print('yes')

	print(Group)
	end

Now this issue with this is I want to figure out if the player is the owner of the group, if the player isn't, I return. If it is, a value will be checked. I added just one line which is as follows.

elseif p:GetRankInGroup(Group) == 255 then

So the code looks like this

game.Players.PlayerAdded:connect(function(p)
	if game.CreatorType == Enum.CreatorType.Group then
	Group = game.CreatorId
	   elseif p:GetRankInGroup(Group) == 255 then
		print('yes')

	print(Group)
	end

But when I publish the module, it doesn't print the group id or yes. How can I fix this?

3 comments

0

Why you don't want to use IF?

0

because if I use it, the code breaks.

0

;-; how dose the code break if you use IF?

1 answer

Okay hopefully I understood this right. You are trying to get to get the rank of a player in a group, then print yes and the groupId.

It seems the only issue was the formatting of the script. I reformatted the script.

game.Players.PlayerAdded:connect(function(p)
	if game.CreatorType == Enum.CreatorType.Group then
		local Group = game.CreatorId
    		if p:GetRankInGroup(Group) == 255 then
			print('yes')
   			print(Group)
		end
	end
end)

I tested this out in one of my games and it seems to work. Hope this helps!

This discussion is preserved as it was. New answers, comments, and votes are closed.