How do I make a updating part counter GUI?

Hello! I’m making a part counter in my game so players can see how many parts are currently generated at the moment, however it doesn’t ever update, I thought that maybe making a while true statement might refresh it but I was clearly wrong, what do I add to the statement so it always updates?

while true do
	local partcount = #workspace.PartFolder:GetChildren()
	script.Parent.Text = partcount
end
1 Like

You can use event ChildAdded to update text when BasePart added to your folder.

local BrickCount = 0

for i, v in pairs(workspace.PartFolder:GetChildren()) do
	if v:IsA("BasePart") then
		BrickCount += 1
	end
	script.Parent.Text = BrickCount
end

workspace.PartFolder.ChildAdded:Connect(function(child)
	if child:IsA("BasePart") then
		BrickCount += 1
	end
	script.Parent.Text = BrickCount
end)
1 Like

Oh that works perfectly thank you very much!