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

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

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

✓ Accepted answer

You can use the player's IsInGroup() function

if(not Player:IsInGroup(4731512))then
	Rank.Value = "Customer"
end

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 comment

1

i like the ternary statement

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