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

How to I have a rank leader stats i made use abbreviations of the group rank and not the exact name?

I made a script for my roblox military group's game, where there is a leaderstats which states your rank in a specific group. because the leaderboard cannot hold the whole name such as the rank "Chief of Defence" because of that i want to change it to COD instead which stands for my rank name. I would like to do this with all the ranks in the group with the script but i do not know how tp make the text an abreviation with your rank and i cannot find any ways to help me with this, please help.

Here is my program so far:

groupid = 8298204

function added (player)
	local ls = Instance.new("IntValue")
	ls.Name = "leaderstats"
	
	local role = Instance.new("StringValue")
	role.Name = "Rank"
	
	role.Value = player:GetRoleInGroup(groupid)
	ls.Parent = player
	role.Parent = ls
end
game.Players.PlayerAdded:Connect(added)

1 answer

✓ Accepted answer

You don't want leaderstats to be an IntValue. Ints (integers) are whole numbers. (like 1, 2, 100 etc.) Instead, you want it to be a folder.

For the role, you can manually set the stringValue and change it whenever you want to

groupid = 8298204

game.Players.PlayerAdded:Connect(function(plr)
	local stats = Instance.new("Folder") --Adds a folder
	stats.Name = leaderstats 
	stats.Parent = plr 

	local role = Instance.new("StringValue") -- Adds a string value
	role.Name = "Rank" 
	role.Parent = stats 
	if plr:IsInGroup(groupid) then -- checks if the player is in the group
		role.Value = "COD"
	elseif role.Value == nil then -- checks if the player doesn't have a role
		role.Value = "Guest" --change "Guest" to whatever you want it to be
	elseif role.Value ~= nil then -- checks if the player has a role
		role.Value = role.Value
	end
end)

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