Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago

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?

0
Why you don't want to use IF? Borrahh 265 — 4y
0
because if I use it, the code breaks. VoidKeyword 111 — 4y
0
;-; how dose the code break if you use IF? Xx0966xX 41 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

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!

Ad

Answer this question