#PlayerRemoving GetChildren only returns first child

5 messages · Page 1 of 1 (latest)

fresh dune
#
game.Players.PlayerRemoving:Connect(function(player)
    local replicated = game:GetService("ReplicatedStorage")
    local pizzas = replicated:FindFirstChild("PlayerPointsStorage"):FindFirstChild(player.Name.."'s Points").Pizzas
    local pizzaSlices = replicated:FindFirstChild("PlayerPointsStorage"):FindFirstChild(player.Name.."'s Points").PizzaSlices

    for i, v in pairs(pizzaSlices:GetChildren()) do
        print("Child: "..v.Name)
    end

This function only prints the name of the first child of pizzaSlices, regardless of how many children exist. In this case that child's name is CrustPizza Interestingly, if I change the CrustPizza's name, it still returns "Child: CrustPizza." If I delete CrustPizza, it still returns "Child: CrustPizza."

The obvious explanation here would be that either pizzaSlices is in the wrong location, or it's checking a previously defined version of pizzaSlices, before the other children get added. But pizzaSlices is in the correct location, and pizzaSlices is defined 4 lines before the for loop so it cannot possibly be checking a previous version.

I cannot find a rational explanation for this.

grave drift
#

Have you tried checking the folder when the player leaves, but on the server?

#

You might have added some childs only on the client

#

If the ones in there on the server are what you want, I have no explaination for this either

fresh dune