I keep getting this error
Workspace.ServerScript:98: attempt to index nil with 'MaxHealth'
the error is coming from this function
function ImplimentData(Player, Humanoid)
for RankName, RankTable in pairs(DataModule.Rank) do
if Update == false then
if RankTable.Name == Player.Data.Rank.Value then
Humanoid.MaxHealth = RankTable.MaxHealth -- this is line 98
end
else
if RankTable.Name == Player.Data.Rank.Value then
if Player.Data.Exp.Value >= RankTable.ExpLimit then
local Difference = Player.Data.Exp.Value - RankTable.ExpLimit
UpdateRankData(Player, RankTable.NextRank)
Player.Data.Exp.Value = Difference
UpdateExpData(Player, Player.Data.Exp.Value)
end
end
end
Update = false
end
end
I identified Humanoid in lines 201 - 209
Players.PlayerAdded:Connect(function(Player) -- lines 201
DataCreate(Player)
GetData(Player)
Player.CharacterAdded:Connect(function(Character)
repeat wait() until Character:FindFirstChild("Humanoid")
local Humanoid = Character.Humanoid
ImplimentData(Player, Humanoid)
end)
end) -- lines 209
DataModule is a ScriptModule in ServerStorage I named it DataModule in ServerStorage but the table name is DataProperties. This is the code
local DataProperties = {
Rank = {
F = {
Name = "F",
MaxHealth = 150,
ExpLimit = 1000,
NextRank = "E"
};
E = {
Name = "E",
MaxHealth = 200,
ExpLimit = 2000,
NextRank = "D"
};
D = {
Name = "D",
MaxHealth = 250,
ExpLimit = 3000,
NextRank = "C"
};
C = {
Name = "C",
MaxHealth = 300,
ExpLimit = 4000,
NextRank = "B"
};
B = {
Name = "B",
MaxHealth = 400,
ExpLimit = 5000,
NextRank = "A"
};
A = {
Name = "A",
MaxHealth = 500,
ExpLimit = 100000000000,
};
};
}
return DataProperties;
Can anyone help me with the error is it because of placement, because i already tried changing the position of the function in the script i still retrieved the same error. Thanks for review my script, your help is appreciated.

3 comments
Where does DataModule.Rank get set?
It is set in a ScriptModule in Server Storage, the code for it is local DataProperties = { Rank = { F = { Name = "F", MaxHealth = 150, ExpLimit = 1000, NextRank = "E" }; return DataProperties; I named the script DataModule but the table DataProperties
DataProperties = { Rank = { F = { Name = "F", MaxHealth = 150, ExpLimit = 1000, NextRank = "E" }; }; return DataProperties;*