Help with plr.Chatted, string.sub

Hello! Basically, I’m trying to make a script, once you type /jail then, apart from the first 5 words, /jail it should detect plr name, but how would I make like, it just doesn’t detect the 10 letter something like >= 10 ? anybody can help?
SCRIPT

game.Players.PlayerAdded:Connect(function(plr)
	game.ReplicatedStorage.Events.Notifcation:FireAllClients("Player Connected", plr.Name.." Joined", 7)
	plr.Chatted:Connect(function(chat)
		if plr:GetRankInGroup(5221664) >= 252 then
			if string.lower(string.sub(chat, 1, 7)) == "/unjail" then
				local letter1 = string.sub(chat, 10)
				game.Players:FindFirstChild(letter1):WaitForChild("Status")["Prison Time"].Value = 0
			elseif  string.lower(string.sub(chat, 1, 5)) == "/jail" then
				local letter1 = string.sub(chat, 10)
				game.Players:FindFirstChild(letter1):WaitForChild("Status")["Prison Time"].Value = 300
			end
		end
	end)
end)

string.len() returns the length of the string, so you could, for example, check from character 6 to the length of the string to pick up any arguments.

Hey, I could sort it out using chat:split(" ")

If you’re going to use string.split() instead of string.sub() then you can skip the first value in the returned array as, at that point, string.sub() is not nessecary

I’m not sure is this what you need but, here:

if chat:lower():sub(1,5) == "/jail" then
    local Name = chat:sub(7)
    print(Name)
end

This should output the name correctly.

Try This

game.Players.PlayerAdded:Connect(function(plr)
	game.ReplicatedStorage.Events.Notifcation:FireAllClients("Player Connected", plr.Name.." Joined", 7)
	plr.Chatted:Connect(function(chat)
		if plr:GetRankInGroup(5221664) >= 252 then
			if string.lower(string.sub(chat, 1, 7)) == "/unjail" then
				local letter1 = string.sub(chat, 9)
				game.Players:FindFirstChild(letter1):WaitForChild("Status")["Prison Time"].Value = 0
			elseif  string.lower(string.sub(chat, 1, 5)) == "/jail" then
				local letter1 = string.sub(chat, 7)
				game.Players:FindFirstChild(letter1):WaitForChild("Status")["Prison Time"].Value = 300
			end
		end
	end)
end)