Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

I need help fixing a Nil Value Problem, What does it mean? Can you help me understand this?

Asked by
Hectiq 2
4 years ago

So, I have a problem, I'm trying to make a Ranking Script (To show the Player Rank above Name) and I (sometimes) get an Error:

Hectiq joined - Debug String
09:05:00.212 - ServerScriptService.Script:7: attempt to index upvalue 'team' (a nil value) - Error
09:05:00.212 - Stack Begin
09:05:00.213 - Script 'ServerScriptService.Script', Line 7
09:05:00.213 - Stack End
09:05:00.942 - ServerScriptService.RankingLabel:7: attempt to index upvalue 'team' (a nil value) - Error
09:05:00.943 - Stack Begin
09:05:00.943 - Script 'ServerScriptService.RankingLabel', Line 7
09:05:00.943 - Stack End

These are My Scripts (TeamList, RankingLabel)

RankingLabel:

local serverStorage = game:GetService("ServerStorage")
local bbg = serverStorage:WaitForChild("RankGui")
local team = _G.team

game.Players.PlayerAdded:Connect(function(player)
    game.Workspace:WaitForChild(player.Name)
    if team[player.Name] == "Owner" then
        local cbbg = bbg:Clone()
        cbbg.Parent = game.Workspace[player.Name].Head
        cbbg.Rank.Text = "Owner"
        cbbg.Rank.TextColor3 = Color3.fromRGB(170,0,0)
        return
    elseif team[player.Name] == "Designer" then
        local cbbg = bbg:Clone()
        cbbg.Parent = game.Workspace[player.Name].Head
        cbbg.Rank.Text = "Designer"
        cbbg.Rank.TextColor3 = Color3.fromRGB(0,0,223)
        return
    else
        local cbbg = bbg:Clone()
        cbbg.Parent = game.Workspace[player.Name].Head
        cbbg.Rank.Text = "Player"
        cbbg.Rank.TextColor3 = Color3.fromRGB(40,40,40)
        return
    end

end)

TeamList:

_G.team = {
    ["Hectiq"] = "Owner";
    ["CENSORED"] = "Designer";
}
return _G.team
0
Don't take my word but a nil value means there is nothing, or no value. You are trying to make the script find a value called "player.Name" in the table, which does not exist. If I were you I would just do If player.Name == "Hectiq" then --stuff it's not the best way tho lol. Nep_Ryker 131 — 4y
0
Hey Xrp! Thanks for the answer! But, i was intentionally trying to make a litte Group System, I'm pretty Sure that will actually repair it, I'm gonna try my litte Group system again, and if it doesn't work maybe i'll change it back! Thanks Hectiq 2 — 4y
0
Glad I could help! Nep_Ryker 131 — 4y
0
I was gonna say the same thing I saw the comment lol Gingerely 245 — 4y

1 answer

Log in to vote
1
Answered by 4 years ago

It seems you're defining _G.team after the script calling for it. Try adding this before calling for _G.team.

repeat wait() until _G.team
Ad

Answer this question