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

If a player is not in my group, I want it to say customer How can I fix this?

Asked by 5 years ago
game.Players.PlayerAdded:connect(function(Player)
    wait(1)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    stats.Value = 0

local Rank = Instance.new("StringValue")

    Rank.Name = "Rank"
    Rank.Value = Player:GetRoleInGroup(4731512)
else
    if Player:GetRoleInGroup(4731512) == 0 then
        Rank.Value = "Customer"
    end

    Rank.Parent = stats
    stats.Parent = Player

end)

2 answers

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

You can use the player's IsInGroup() function

if(not Player:IsInGroup(4731512))then
    Rank.Value = "Customer"
end
Ad
Log in to vote
0
Answered by
Azarth 3141 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

Remove else and did you mean GetRankInGroup? GetRoleInGroup returns a string.

local function PlayerAdded(Player)
    local stats = Instance.new("IntValue")
    stats.Name = "leaderstats"
    stats.Value = 0

    local Rank = Instance.new("StringValue")
    Rank.Name = "Rank"  
    Rank.Value = Player:IsInGroup(4731512) and 'Customer' or 'Guest'

    Rank.Parent = stats
    stats.Parent = Player
end

game.Players.PlayerAdded:Connect(function(Player)
    PlayerAdded(Player)
end)

for _, Player in  pairs (game.Players:GetPlayers()) do
    PlayerAdded(Player)
end
1
i like the ternary statement royaltoe 5144 — 5y

Answer this question