My script is not able to reference a value from a module script.
For reference, Ranks is a module script located in ServerScriptService.
It contains a table full of ranks, but all that you need to see is this:
local Ranks = {}
Ranks.RankValues = {
["Baron"] = {12, 2500, Color3.fromRGB(255,255,0)}
}
return Ranks
Another script in ServerScriptService runs when the player is added:
local Players = game:GetService("Players")
local Ranks = require(game:GetService("ServerScriptService"):WaitForChild("Ranks"))
Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Character)
local Rank = plr:WaitForChild("Rank") --This exists already from another script
if Ranks.RankValues[plr.Rank.Value][1] <= 4 then --Assume Rank = "Baron"
--Do things
end
end)
end)
The output errors that I am attempting to index nil with number on the line where it says
if Ranks.RankValues[plr.Rank.Value][1] <= 4 then
.
This error occurs while my Rank value equals “Baron”. It’s a string value just like in the table. The error happens in multiple different scripts while trying to perform similar checks.
According to the module script, Ranks.RankValues[“Baron”][1] SHOULD equal 12, though, not nil? Any ideas as to why this doesn’t get checked properly?