I tried to make a script where it prints the amount of bricks in workspace, but they dont do nor work as their supposed to, here are the scripts
c=workspace:children() for i=1,#c do if c.className=="Part"then print(c) end end
That didn't print anything, so I then tried this;
c=workspace:children() for i,v in ipairs(c)do --Did 'pairs' too if v:IsA("Part")then print(v) end end
It only print the names of the Brick(s), what am I doing wrong?
This is a script that scans through the descendants of the Workspace and adds those bricks to the list too, instead of just scanning the Workspace
local PartCount = 0 function GetPartCount(Obj) for _,v in pairs(Obj:GetChildren()) do if v:IsA("BasePart") then PartCount = PartCount + 1 end GetPartCount(v) end end GetPartCount(game.Workspace) print("There are "...PartCount.." parts in the Workspace!")
This will scan through models in the workspace, and the models of those models, and so forth.
If you only want the personal copy, I recommend using a NumberValue in Workspace, then doing this:
c = Workspace:GetChildren() for i = 1, #c do if c:IsA("Part") then game.Workspace.NumberValue.Value = game.Workspace.NumberValue.Value + 1 end end
I'm Aurum, and you're welcome.
c = game.Workspace:GetChildren if c.ClassName=="Part then" print(#c) end