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
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)