So I'm trying to make a rank system that's based on the player's level, but when I tried to make it it did not work. Is it even possible to do this, and if it's not is there any other way?
---//Error\---
ServerScriptService.LeaderStats.RankHandler:9: invalid argument #3 (string expected, got nil)
--//RankScript\---
---//Services\\---
local ReplicatedStorage = game:GetService("ReplicatedStorage")
--//ServiceChildren\\--
local USRankHandler = require(ReplicatedStorage.RankHandler:WaitForChild("USRankHandler"))
local VRankHandler = require(ReplicatedStorage.RankHandler:WaitForChild("VRankHandler"))
---//Script\\---
game.Players.PlayerAdded:Connect(function(player)
if player.TeamColor == BrickColor.new("Cyan") then
player:WaitForChild("leaderstats").Rank.Value = USRankHandler.Rank(player:WaitForChild("leaderstats2").Level.Value) ---Rank is a StringValue level is a IntValue
player.leaderstats2.Level:GetPropertyChangedSignal("Value"):Connect(function()
player:WaitForChild("leaderstats").Rank.Value = USRankHandler.Rank(player:WaitForChild("leaderstats2").Level.Value)
end)
end
end)
---//ModuleScript\---
local USRank = {}
local players = game.Players
local player = players.LocalPlayer
USRank.Rank = function(USR)
if USR == 1 then
USR = "Private"
elseif USR == 2 then
USR = "PFC"
elseif USR == 3 then
USR = "Corporal"
elseif USR == 4 then
USR = "Sergeant"
elseif USR == 5 then
USR = "Staff Sergeant"
elseif USR == 6 then
USR = "Technical Sergeant"
elseif USR == 7 then
USR = "First Sergeant"
elseif USR == 8 then
USR = "Master Sergeant"
elseif USR == 9 then
USR = "Second Lieutenant"
elseif USR == 10 then
USR = "First Lieutenant"
elseif USR == 11 then
USR = "Captain"
elseif USR == 12 then
USR = "Major"
elseif USR == 13 then
USR = "Lieutenant Colonel"
elseif USR == 14 then
USR = "Colonel"
elseif USR == 15 then
USR = "Brigadier General"
elseif USR == 16 then
USR = "Major General"
elseif USR == 17 then
USR = "Lt.General"
elseif USR == 18 then
USR = "General"
elseif USR == 19 then
USR = "General of the army"
elseif USR >= 20 then
USR = (USR).."CINC"
end
end
return USRank
---//P.S\---
I'm new to module scripts. So please understand why I'm having a hard time with something like this.
