-
Notifications
You must be signed in to change notification settings - Fork 0
Documentation: ClearAll
Summary: This function removes all children of an instance that belong to a specified class.
Syntax: ClearAllChildrenWhichAre(Ancestor: Instance, ClassName: string) → number
-
Ancestor
: An instance that represents the parent object from which children will be removed. -
ClassName
: A string that represents the class name of the children that will be removed.
-
number
: The total number of instances that has been destroyed.
local Part = Instance.new("Part")
Part.Parent = game.Workspace
Part.Name = "PartA"
local Part = Instance.new("Part")
Part.Parent = game.Workspace
Part.Name = "PartB"
local Cleared = Clear.ClearAllChildrenWhichAre(game.Workspace, "Part")
print(Cleared) -- Output: 2
Summary: This function removes all children of an instance that belong to a specified class.
Syntax: ClearAllDescendantsWhichAre(Ancestor: Instance, ClassName: string) → number
-
Ancestor
: An instance representing the ancestor object whose descendants are to be cleared. -
ClassName
: A string representing the name of the class that the descendants to be cleared should belong to.
-
number
: A number representing the number of descendants that were cleared.
local Part = workspace.Part
local Destroyed = Clear.ClearAllDescendantsWhichAre(Part, "Script")
print(string.format("Cleared %d descendants which are of class 'Script'", Destroyed))
Summary: Destroys all children of the given ancestor except for those that match certain criteria specified in the Excluded table.
Syntax: ClearAllChildrenExcept(Ancestor: Instance, Excluded: {[string]: any}) → number
-
Ancestor
: An instance representing the ancestor object whose children will be destroyed, except for those specified in theExcluded
table. -
Excluded
: A table that specifies the children of Ancestor that should be excluded from being destroyed. This table can have three keys:-
Instances
: An array of instance objects or strings representing the names of instances that should not be destroyed. -
Properties
: A table of property-value pairs representing the properties and values that the instances to be preserved must have. If a child’s property matches the given value, then that child will be excluded from being destroyed. -
IsA
: A string representing the class name that the instances to be preserved must be an instance of.
-
-
number
: An integer representing the number of children that were destroyed.
local Excluded = {
Instances = {Part},
Properties = {
Name = "Model"
},
IsA = "Model"
}
Clear.ClearAllDescendantsExcept(game.Workspace, Excluded)
--| The above code should destroy all instances in the workspace except any instance that is a 'Part' or having any of the names: 'Part1', 'Part2', 'MyPart' And if it has the property 'Transparency' with the value of 1.
Summary: Same as the above function. Destroys all descendants of the given ancestor except the ones specified in the Excluded
table. It returns then the number of children that were destroyed.
Syntax: ClearAllDescendantsExcept(Ancestor: Instance, Excluded: {[string]: any}) → number
-
Ancestor
: An instance object representing the ancestor whose children will be destroyed. -
Excluded
: A table that specifies the children of Ancestor that should be excluded from being destroyed. This table can have three keys:-
Instances
: An array of instance objects or strings representing the names of instances that should not be destroyed. -
Properties
: A table of property-value pairs that an instance must have to be excluded from the destruction process. -
IsA
: A string representing the class name that the instances to be preserved must be an instance of.
-
-
number
: An integer representing how many descendants that were destroyed.
local Part = game.Workspace.Part
local Excluded = {
Instances = {Part},
Properties = {
Name = "Model"
},
IsA = "Model"
}
Clear.ClearAllDescendantsExcept(game.Workspace, Excluded)
--| The above code should destroy all descendants of game.Workspace, except for the instance Part and any other instances that have the property Name set to "Model" or belong to the "Model" class.