ServiceProvider
Inherits Instance
ServiceProvider is an abstract class that manages singleton service instances.
Properties
Methods
GetService(serviceName: string)
InstanceGets a service by name, creating it if it doesn't exist
Parameters:
serviceNamestring
local workspace = game:GetService("Workspace")
FindService(serviceName: string)
Instance | nilFinds a service by name without creating it
Parameters:
serviceNamestring
local workspace = game:FindService("Workspace")
if workspace then
print("Workspace exists")
end
Checks if this instance has a specific tag
Parameters:
tagstring
Removes a tag from this instance
Parameters:
tagstring
Gets the value of an attribute
Parameters:
attributestring
Returns a table of all attributes
Sets the value of an attribute
Parameters:
attributestringvalueAttribute
part:SetAttribute("Health", 100)
local health = part:GetAttribute("Health")
Finds the first ancestor with the specified name
Parameters:
namestring
Finds the first ancestor of the specified class
Parameters:
classNamestring
Finds the first ancestor that is an instance of the class
Parameters:
classNamestring
Finds the first direct child with the specified name
Parameters:
namestring
Finds the first direct child of the specified class
Parameters:
namestring
Finds the first child that is an instance of the class
Parameters:
namestring
Finds the first descendant with the specified name
Parameters:
namestring
Returns an array of all direct children
for _, child in ipairs(workspace:GetChildren()) do
print(child.Name)
end
Returns an array of all descendants
Checks if this instance is an ancestor of the target
Parameters:
descendantInstance
Checks if this instance is a descendant of the target
Parameters:
ancestorInstance
Removes and destroys all children
Permanently destroys this instance and all descendants
Sets the parent of this instance
Parameters:
newParentInstance - | nil
Adds a child to this instance
Parameters:
childInstance
Events
Fires when the instance's ancestry changes
Fires when an attribute is changed
Fires when a child is added to this instance
Fires when a child is removed from this instance
Fires when a descendant is added anywhere in the tree
Fires when a descendant is about to be removed
Fires when this instance is being destroyed