Ranking system not working?

So I have values in players and its not working, any help? No output errors.

local Rank = {
    [1] = "Police Cadet",
    [2] = "Police Officer",
	[3] = "Police Corporal",
	[4] = "Police Sergeant",
	[5] = "Police Lieutenant",
	[6] = "Police Captain",
	[7] = "Deputy Cheif of Police",
	[8] = "Cheif of Police",
	[9] = "Police Commissioner",
	[10] = "Assistant Police Commissioner",
}

game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function(Character)
   if Player.Team == game.Teams.NYPD then
	wait(2)
	local val = Player:WaitForChild("stats"):WaitForChild("PoliceRank").Value
    if val >= 1 then
    wait(0.5)
    if val >= #Rank then
	PT.F.T.Text =(Rank[#Rank])
	PT.F.T.TextColor3 = Color3.new(54,108,162)

It doesn’t change the value of the text to the rank. (Also forgot this in the script above)

	Character:WaitForChild("Head"):WaitForChild("Title").F.T.TextColor3 = Color3.fromRGB(54, 108, 162)
	local PT = script.PoliceTitle:Clone()
	PT.Parent = Character.Head

But it specifies what rank goes where with the value of “1” being police cadet, as reference.

Please format code properly when you post it, I would like to help but I can hardly tell what is going on here. Normally I would look at code formatted like this and just move on, but I might have noticed something that is an issue. I say might be because again, I cannot tell.

The second is statement seems to check if the rank is only equal to or greater than the last. What is it supposed to do if the rank is in the range of [1 #Rank)? Also when debugging “it’s not running” issues it help to either use break points in the debugger or put print statements to see where it stops printing. In particular, right before and after the WaitForChild calls seems like a likely place to cause an issue. Particularly if the “PoliceRank” stat was actually “Police Rank” or something like that.

It’s worth noting that a list of strings as you suggested is stored in the array section, not the dictionary. His code will work the exact same either with the '[x] = ’ or without them. (note that this only works when x is a number, starts at 1, is continuous with a step size of 1, and ordered from least to greatest).

Alright I just fixed it, added some more checks and else statements. Also used WaitForChild and it all worked out.