I did some tinkering and I’ve fixed it. Here’s the code for anyone who would like to use it 
local HttpService = game:GetService("HttpService")
local ReplicatedStorage = game.ReplicatedStorage
local AppUrl = script.AppUrl.Value
local ApiKey = script.ApiKey.Value
local Groupid = script.GroupId.Value
local MinRank = script.MinRank.Value
local prefix = "!"
local function FindPlr(plr)
local foundPlr = nil
local plrs = game.Players:GetPlayers()
for i = 1, #plrs do
local current = plrs[i]
if string.lower(current.Name):sub(1, #plr) == string.lower(plr) then
foundPlr = current.Name
break
end
end
return foundPlr
end
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if player:GetRankInGroup(Groupid) >= 2 then
local LowerCaseMessage = string.lower(msg)
if string.find(LowerCaseMessage, "!rank") then --Look for the rank command to be used
local SplitMessage = string.split(msg, " ") --Split the message
local full_player = FindPlr(SplitMessage[2]) --Get the 2nd word in the message
local playerInstance = game.Players:FindFirstChild(player.Name)
local req_rank = SplitMessage[3]
local found = game.Players:FindFirstChild(full_player)
print(found:GetRankInGroup(Groupid))
if string.match(req_rank, 'Constable') and found:GetRankInGroup(Groupid) < 6 then
local offrank = 6
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name) --Get the player that sent the command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh","We couldn't find the player you wanted to rank!") --Notify the client that it failed.
else --if player exsists
local playerInstance = game.Players:FindFirstChild(player.Name) --Find player that sent command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Attempting.","Attempting to rank user...") --Send loading.
local Url = "https://"..AppUrl.."/group/rank?username="..full_player.."&key="..ApiKey.."&groupid="..Groupid.."&role_number="..offrank --Add RoleNumber To The Data sent to the WebServer.
local success, response = pcall(function(data) --Pcall for obvious reasons
local response = HttpService:GetAsync(Url) --Send request to webserver
local data = HttpService:JSONDecode(response) --Decode Json Data.
end)
if success then --test if worked.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Success!", ""..full_player.." has has passed the LR training, and has been ranked as "..req_rank..".") --Custom edited the error messages.
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful","The command failed") --Custom edited the error messages.
end
end
elseif string.match(req_rank, 'Constable') and found:GetRankInGroup(Groupid) >= 6 then
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful",""..full_player.." Is already a Constable or higher rank.") --Custom edited the error messages.
elseif string.match(req_rank, 'Corporal') and found:GetRankInGroup(Groupid) < 7 then
local offrank = 7
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name) --Get the player that sent the command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh","We couldn't find the player you wanted to rank!") --Notify the client that it failed.
else --if player exsists
local playerInstance = game.Players:FindFirstChild(player.Name) --Find player that sent command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Attempting.","Attempting to rank user...") --Send loading.
local Url = "https://"..AppUrl.."/group/rank?username="..full_player.."&key="..ApiKey.."&groupid="..Groupid.."&role_number="..offrank --Add RoleNumber To The Data sent to the WebServer.
local success, response = pcall(function(data) --Pcall for obvious reasons
local response = HttpService:GetAsync(Url) --Send request to webserver
local data = HttpService:JSONDecode(response) --Decode Json Data.
end)
if success then --test if worked.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Success!", ""..full_player.." has has passed the LR training, and has been ranked as "..req_rank..".") --Custom edited the error messages.
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful","The command failed") --Custom edited the error messages.
end
end
elseif string.match(req_rank, 'Corporal') and found:GetRankInGroup(Groupid) >= 7 then
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful",""..full_player.." Is already a Corporal or higher rank.") --Custom edited the error messages.
elseif string.match(req_rank, 'Sergeant') and found:GetRankInGroup(Groupid) < 8 then
local offrank = 8
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name) --Get the player that sent the command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh","We couldn't find the player you wanted to rank!") --Notify the client that it failed.
else --if player exsists
local playerInstance = game.Players:FindFirstChild(player.Name) --Find player that sent command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Attempting.","Attempting to rank user...") --Send loading.
local Url = "https://"..AppUrl.."/group/rank?username="..full_player.."&key="..ApiKey.."&groupid="..Groupid.."&role_number="..offrank --Add RoleNumber To The Data sent to the WebServer.
local success, response = pcall(function(data) --Pcall for obvious reasons
local response = HttpService:GetAsync(Url) --Send request to webserver
local data = HttpService:JSONDecode(response) --Decode Json Data.
end)
if success then --test if worked.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Success!", ""..full_player.." has has passed the LR training, and has been ranked as "..req_rank..".") --Custom edited the error messages.
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful","The command failed") --Custom edited the error messages.
end
end
elseif string.match(req_rank, 'Sergeant') and found:GetRankInGroup(Groupid) >= 8 then
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful",""..full_player.." Is already a Sergeant or higher rank.") --Custom edited the error messages.
elseif string.match(req_rank, 'Lieutenant') and found:GetRankInGroup(Groupid) < 9 then
local offrank = 9
if full_player == nil then
local playerInstance = game.Players:FindFirstChild(player.Name) --Get the player that sent the command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Uh-Oh","We couldn't find the player you wanted to rank!") --Notify the client that it failed.
else --if player exsists
local playerInstance = game.Players:FindFirstChild(player.Name) --Find player that sent command.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Attempting.","Attempting to rank user...") --Send loading.
local Url = "https://"..AppUrl.."/group/rank?username="..full_player.."&key="..ApiKey.."&groupid="..Groupid.."&role_number="..offrank --Add RoleNumber To The Data sent to the WebServer.
local success, response = pcall(function(data) --Pcall for obvious reasons
local response = HttpService:GetAsync(Url) --Send request to webserver
local data = HttpService:JSONDecode(response) --Decode Json Data.
end)
if success then --test if worked.
game.ReplicatedStorage.Notify:FireClient(playerInstance, "Success!", ""..full_player.." has has passed the LR training, and has been ranked as "..req_rank..".") --Custom edited the error messages.
else
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful","The command failed") --Custom edited the error messages.
end
end
elseif string.match(req_rank, 'Lieutenant') and found:GetRankInGroup(Groupid) >= 9 then
game.ReplicatedStorage.Notify:FireClient(playerInstance, "UnSuccessful",""..full_player.." Is already a Lieutenant or higher rank.") --Custom edited the error messages.
end
end
end
end)
end)
@HayHay You said you were attempting to achieve this, so here you go.
All you have to do is edit the rank numbers and the messages and you’re done.