I know this is probably really easy to do, but i unfortunately could not find what i’m looking for.
I am making a pet inventory and i was wondering how to make a pet counter, [example:“200 pets”] for the inventory that gets the children from the player pets folder.
It is really easy to do, you just have to do something like this.
local PLAYER = game.Players.LocalPlayer
local PLAYER_PETS_FOLDER: Folder = PLAYER.PetsFolder -- change this to whereever your pet folder is
local LABEL: TextLabel = script.Parent -- change this to whereever your label is
local function updateLabel()
local pet_amount = #PLAYER_PETS_FOLDER:GetChildren()
LABEL.Text = string.format("%s pets", pet_amount)
end
updateLabel()
PLAYER_PETS_FOLDER.ChildAdded:Connect(updateLabel)
PLAYER_PETS_FOLDER.ChildRemoved:Connect(updateLabel)