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

Attempt to index nil with 'FindFirstChild'?

Asked by 2 years ago

As the title says, 'FindFirstChild' is a nil value. It's on the second line of code. Can someone help me?

for keyvalue, player in pairs(game.Players:GetPlayers()) do
            if player.Character:FindFirstChild("Humanoid") then
                if player.Character.Humanoid.Health >= 1 then
                    table.insert(PlayersInGame, keyvalue, player)
                    player.Team = game.Teams.Players
                    player.Character.Humanoid.Died:Connect(function()
                        for i = 1, #PlayersInGame do
                            if PlayersInGame[i] == player then
                                SelectBox(player.Character:FindFirstChild("PlateValue").Value)
                                local TransInfo = TweenInfo.new(
                                    2,
                                    Enum.EasingStyle.Linear,
                                    Enum.EasingDirection.Out,
                                    0,
                                    false,
                                    0
                                )
                                local Tween = TweenService:Create(player.Character:FindFirstChild("PlateValue").Value, TransInfo, {Transparency = 1}):Play()
                                coroutine.wrap(function()
                                    wait(2)
                                    player.Character:FindFirstChild("PlateValue").Value:Destroy()
                                end)
                                table.remove(PlayersInGame, i)
                                if player.Team == game.Teams.Players then
                                    player.Team = game.Teams["Lobby"]
                                end
                            end
                        end
                    end)
0
Try WaitForChild() on your second line of code RichDiggerW189 2 — 2y
0
Thanks! It worked! aydenwilson819 25 — 2y

Answer this question