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

Attempt to index nil with number (line 23)?

Asked by 3 years ago
local ServerStorage = game:GetService("ServerStorage")
local Tags = ServerStorage:WaitForChild("PlayerTags")
local RankColors = {
    Owner = {Color3.fromRGB(255, 0, 0)};
    Admin = {Color3.fromRGB(255, 0, 0)};
    Moderator = {Color3.fromRGB(42, 126, 0)};
    YouTuber = {Color3.fromRGB(255, 0, 0)};
    MVP = {Color3.fromRGB(0, 202, 202)};
    VIP = {Color3.fromRGB(85, 255, 0)};
    Default = {Color3.fromRGB(109, 109, 109)};
}

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(Character)

        for i,v in pairs(Tags:GetChildren()) do
            if v.Name == "NameTag" then
                local ClonedTag = Tags:FindFirstChild(v.Name):Clone()
                ClonedTag.Parent = Character.Head
                ClonedTag.UpperText.Text = player.Name
                ClonedTag.LowerText.Text = player.Rank.Value
                if RankColors ~= nil then
                    ClonedTag.LowerText.TextColor3 = RankColors[player.Rank.Value][1]
                end
            else
                local ClonedTag = Tags.HealthGui:Clone()
                ClonedTag.Parent = Character.Head
            end
        end
    end)
end)

Answer this question