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

Can I make a group rank to game script?

Asked by 6 years ago

What I am trying to do is connect one of my SCPF groups with the game I am currently making, so basically, Level-1 will get "[SCP] Card-L1", Level-2 will get "[SCP] Card-L2" etc.

I have been trying scripts from everywhere, please help...

1 answer

Log in to vote
0
Answered by
Avigant 2374 Moderation Voter Community Moderator
6 years ago

We can build a table to map rank names (otherwise known as roles) to titles, and look up the player's role in it:

local GroupId = 1
local Prefix = "[SCP]"
local GroupRoleToTitle = {
    ["Level-1"] = "Card-L1",
    ["Level-900"] = "Really High Level Person With a Lot of Authority"
}

local function OnPlayerAdded(Player)
    local Role = Player:GetRoleInGroup(GroupId)
    local Title = GroupRoleToTitle[Role]

    print(Title) --> The title!
end

local Players = game.Players:GetPlayers()

for Index = 1, #Players do
    -- Just in case players join before the event is connected in Studio!
    local Player = Players[Index]

    OnPlayerAdded(Player)
end

game.Players.PlayerAdded:Connect(OnPlayerAdded)
Ad

Answer this question