I want a function to connect when the game finds that there is only 1 object in a certain place. Let's say if there's only 1 block named "Brick" in the workspace. How would I tell a script to do something if there's only 1 of them? I have no idea how to even start a script like this.
Thanks for reading
You could use a for loop:
local function howmanyParts(model) local nrofparts for i, v in pairs(model:GetChildren)) do nrofparts = nrofparts + 1 end return nrofparts end
Or (im not sure if this works though):
local function howmanyParts(model) local nrofparts = model:GetChildren() return #nrofparts end
In each example, the model parameter represents the model that contains the number of parts you want to count. So to print the numbers of instances in the workspace you could do print(howmanyParts(game.Workspace)