-
Notifications
You must be signed in to change notification settings - Fork 7
server.components.Weapon.WeaponInstance
server/components/Weapon.WeaponInstance
-
↳
WeaponInstance
- AncestryChanged
- Archivable
- AttributeChanged
- BodyAttach
- Changed
- ChildAdded
- ChildRemoved
- ClassName
- DescendantAdded
- DescendantRemoving
- DmgPart
- Name
- Parent
- PrimaryPart
- WorldPivot
- BreakJoints
- ClearAllChildren
- Clone
- Destroy
- FindFirstAncestor
- FindFirstAncestorOfClass
- FindFirstAncestorWhichIsA
- FindFirstChild
- FindFirstChildOfClass
- FindFirstChildWhichIsA
- FindFirstDescendant
- GetActor
- GetAttribute
- GetAttributeChangedSignal
- GetAttributes
- GetBoundingBox
- GetChildren
- GetDescendants
- GetExtentsSize
- GetFullName
- GetModelCFrame
- GetModelSize
- GetPivot
- GetPrimaryPartCFrame
- GetPropertyChangedSignal
- IsA
- IsAncestorOf
- IsDescendantOf
- MakeJoints
- MoveTo
- PivotTo
- ResetOrientationToIdentity
- SetAttribute
- SetIdentityOrientation
- SetPrimaryPartCFrame
- TranslateBy
- WaitForChild
• Readonly AncestryChanged: RBXScriptSignal<fn>
Fires when the Instance.Parent property of the object or one of its ancestors is changed.
This event includes two parameters, child and parent. Child refers to the Instance whose Instance.Parent was actually changed. Parent refers to this Instance's new Instance.Parent.
A common use for this function is detecting when an object has been removed or destroyed (using Instance:Destroy). This is done by checking if the parent has been set to nil. For example:
object.AncestryChanged:Connect(function(_, parent) if not parent then print("object destroyed!") end end)
node_modules/@rbxts/types/include/generated/None.d.ts:936
• Archivable: boolean
This property determines whether an object should be included when the game is published or saved, or when Instance:Clone is called on one of the object's ancestors. Calling Clone directly on an object will return nil if the cloned object is not archivable. Copying an object in Studio (using the 'Duplicate' or 'Copy' options) will ignore the Archivable property and set Archivable to true for the copy.
local part = Instance.new("Part") print(part:Clone()) --> Part part.Archivable = false print(part:Clone()) --> nil
node_modules/@rbxts/types/include/generated/None.d.ts:447
• Readonly AttributeChanged: RBXScriptSignal<fn>
This event fires whenever an attribute is changed on the instance. This includes when an attribute is set to nil. The name of the attribute that has been changed is passed to the connected function.
For example, the following code snippet will connect the AttributeChanged function to fire whenever one of Instance's attributes changes. Note that this code sample does not define Instance:
local function attributeChanged(attributeName) print(attributeName, “changed”) end
instance.AttributeChanged:Connect(attributeChanged)
- Instance:SetAttribute, sets the attribute with the given name to the given value
- Instance:GetAttribute, returns the attribute which has been assigned to the given name
- Instance:GetAttributes, returns a dictionary of string → variant pairs for each of the instance's attributes
- Instance:GetAttributeChangedSignal, returns an event that fires when the given attribute changes
node_modules/@rbxts/types/include/generated/None.d.ts:956
• BodyAttach: BasePart
src/server/components/Tool.ts:34
• Readonly Changed: unknown
The Changed event fires right after most properties change on objects. It is possible to find the present value of a changed property by using object[property]. To get the value of a property before it changes, you must have stored the value of the property before it changed.
If you are only interested in listening to the change of a specific property, consider using the GetPropertyChangedSignal method instead to get an event that only fires when a given property changes.
This event does not fire for physics-related changes, like when the CFrame, Velocity, RotVelocity, Position, Orientation and CFrame properties of a BasePart change due to gravity. To detect changes in these properties, consider using a physics-based event like RunService.Stepped or BasePart.Touched. A while-true-do loop can also work.
For “-Value” objects, this event behaves differently: it only fires when the Value property changes. See individual pages for IntValue, StringValue, etc for more information. To detect other changes in these objects, you must use GetPropertyChangedSignal instead.
node_modules/@rbxts/types/include/generated/None.d.ts:966
• Readonly ChildAdded: RBXScriptSignal<fn>
Fires when an object is parented to this Instance.
Note, when using this function on a client to detect objects created by the server it is necessary to use Instance:WaitForChild when indexing these object's descendants. This is because the object and its descendants are not guaranteed to replicate from the server to the client simultaneously. For example:
workspace.ChildAdded:Connect(function(child) -- need to use WaitForChild as descendants may not have replicated yet local head = child:WaitForChild("Head") end)
Note, this function only works for immediate children of the Instance. For a function that captures all descendants, use Instance.DescendantAdded.
See also, Instance.ChildRemoved.
node_modules/@rbxts/types/include/generated/None.d.ts:981
• Readonly ChildRemoved: RBXScriptSignal<fn>
Fires when a child is removed from this Instance.
Removed refers to when an object's parent is changed from this Instance to something other than this Instance. Note, this event will also fire when a child is destroyed (using Instance:Destroy) as the destroy function sets an object's parent to nil.
This function only works for immediate children of the Instance. For a function that captures all descendants, use Instance/DescendantRemoved.
See also Instance.ChildAdded.
node_modules/@rbxts/types/include/generated/None.d.ts:991
• Readonly ClassName: string
A read-only string representing the class this Instance belongs to.
This property can be used with various other functions of Instance that are used to identify objects by type, such as Instance:IsA or Instance:FindFirstChildOfClass.
Note this property is read only and cannot be altered by scripts. Developers wishing to change an Instance's class will instead have to create a new Instance.
Unlike Instance:IsA, ClassName can be used to check if an object belongs to a specific class ignoring class inheritance. For example:
for _, child in ipairs(game.Workspace:GetChildren()) do if child.ClassName == "Part" then print("Found a Part") -- will find Parts in model, but NOT TrussParts, WedgeParts, etc end end Tags: ReadOnly, NotReplicated
node_modules/@rbxts/types/include/generated/None.d.ts:465
• Readonly DescendantAdded: RBXScriptSignal<fn>
The DescendantAdded even fires when a descendant is added to the Instance.
As DescendantAdded fires for every descendant, parenting an object to the Instance will fire the event for this object and all of its descendants individually.
Developers only concerned with the immediate children of the Instance should use Instance.ChildAdded instead.
See also Instance.DescendantRemoving.
node_modules/@rbxts/types/include/generated/None.d.ts:1001
• Readonly DescendantRemoving: RBXScriptSignal<fn>
DescendantRemoving fires immediately before the Parent of a descendant of the Instance changes such that the object is no longer a descendant of the Instance. Destroy and Remove change an object's Parent to nil, so calling these on a descendant of an object will therefore cause this event to fire.
Since this event fires before the the descendant's removal, the Parent of the descendant will be unchanged, i.e., it will still be a descendant at the time of this event firing. If the descendant is also a child of the object, It will also fire before ChildRemoved. There is no similar event called “DescendantRemoved”.
If a descendant has children, this event fires with the descendant first followed by its descendants.
The example below should help clarify how DescendantRemoving fires when there are several objects involved.
- Calling Remove on PartA would cause DescendantRemoving to fire on both ModelA and Model, in that order.
- Setting the Parent of PartA to ModelB would cause DescendantRemoving to fire on ModelA but not Model (as Model would still be an ancestor of PartA).
- Calling Destroy on ModelA would cause DescendantRemoving to fire multiple times on several objects:
- On Model with ModelA, PartA then FireA.
- On ModelA, with PartA then FireA.
- On PartA with FireA.
This event fires with the descendant object that is being removed. Attempting to set the Parent of the descendant being removed to something else will fail with the following warning: “Something unexpectedly tried to set the parent of X to Y while trying to set the parent of X. Current parent is Z”, where X is the removing descendant, Y is the ignored parent setting, and Z is the original parent of X. Below is an example that demonstrates this:
workspace.DescendantRemoving:Connect(function(descendant) -- Don't manipulate the parent of descendant in this function! -- This event fires BECAUSE the parent of descendant was manipulated, -- and the change hasn't happened yet, i.e. this function fires before that happens. -- Therefore, it is problematic to change the parent like this: descendant.Parent = game end) local part = Instance.new("Part") part.Parent = workspace part.Parent = nil -- This triggers DescendantRemoving on Workspace: --> Something unexpectedly tried to set the parent of Part to NULL while trying to set the parent of Part. Current parent is Workspace.
See also DescendantAdded.
ToolInstance.DescendantRemoving
node_modules/@rbxts/types/include/generated/None.d.ts:1042
• DmgPart: BasePart & { End: Attachment ; Start: Attachment }
src/server/components/Weapon.ts:31
• Name: string
A non-unique identifier of the Instance.
This property is an identifier that describes an object. Names are not necessarily unique identifiers however; multiple children of an object may share the same name. Names are used to keep the object hierarchy organized, along with allowing scripts to access specific objects.
The name of an object is often used to access the object through the data model hierarchy using the following methods:
local baseplate = workspace.Baseplate local baseplate = workspace["Baseplate"] local baseplate = workspace:FindFirstChild("BasePlate")
In order to make an object accessible using the dot operator, an object's Name must follow a certain syntax. The objects name must start with an underscore or letter. The rest of the name can only contain letters, numbers, or underscores (no other special characters). If an objects name does not follow this syntax it will not be accessible using the dot operator and Lua will not interpret its name as an identifier.
If more than one object with the same name are siblings then any attempt to index an object by that name will return the only one of the objects found similar to Instance:FindFirstChild, but not always the desired object. If a specific object needs to be accessed through code, it is recommended to give it a unique name, or guarantee that none of its siblings share the same name as it.
Note, a full name showing the instance's hierarchy can be obtained using Instance:GetFullName.
node_modules/@rbxts/types/include/generated/None.d.ts:483
• Parent: undefined | Instance
The Parent property determines the hierarchical parent of the Instance. The following terminology is commonly used when talking about how this property is set:
- An object is a child (parented to) another object when its Parent is set to that object.
- The descendants of an Instance are the children of that object, plus the descendants of the children as well.
- The ancestors of an Instance are all the objects that the Instance is a descendant of.
It is from this property that many other API members get their name, such as GetChildren and FindFirstChild.
The Remove function sets this property to nil. Calling Destroy will set the Parent of an Instance and all of its descendants to nil, and also lock the Parent property. An error is raised when setting the Parent of a destroyed object.
This property is also used to manage whether an object exists in the game or needs be be removed. As long as an objects parent is in the DataModel, is stored in a variable, or is referenced by another objects property, then the object remains in the game. Otherwise, the object will automatically be removed. The top level DataModel object (the one referred to as the game by scripts) has no parent, but always has a reference held to it by the game engine, and exists for the duration of a session.
Newly created objects using Instance.new will not have a parent, and usually will not be visible or function until one is set. The most elementary creation of an object has two steps: creating the object, then setting its parent.
-- Create a part and parent it to the workspace local part = Instance.new("Part") part.Parent = workspace -- Instance new can also take Parent as a second parameter Instance.new("NumberValue", workspace)
An object created by server will not replicate to clients until it is parented to some object that is replicated. When creating an object then setting many properties, it's recommended to set Parent last. This ensures the object replicates once, instead of replicating many property changes.
local part = Instance.new("Part") -- Avoid using the second parameter here part.Anchored = true part.BrickColor = BrickColor.new("Really red") -- Potentially many other property changes could go here here... -- Always set parent last! part.Parent = workspace
However, if you were parenting your parts to a Model whose parent hasn't been set yet, then setting the parent first would not matter as the model would not have replicated yet. Tags: NotReplicated
node_modules/@rbxts/types/include/generated/None.d.ts:520
• PrimaryPart: undefined | BasePart
Points to the primary part of the Model. The primary part is the BasePart that acts as the physical reference for the pivot of the model. That is, when parts within the model are moved due to physical simulation or other means, the pivot will move in sync with the primary part. If the primary part is not set, the pivot will remain at the same location in world space even if parts within the model are moved.
Note that when setting this property, it must be a BasePart that is a descendant of the model. If you try to set Model.PrimaryPart to a BasePart that is not a descendant of the model, it will be set to that part but reset to nil during the next simulation step — this is legacy behavior to support scripts which assume they can temporarily set the primary part to a BasePart which isn't a descendant of the model.
The general rule for models is that:
- Models whose parts are joined together via physical joints such as WeldConstraints or Motor6Ds should have a primary part assigned. For example, Roblox character models have their Model.PrimaryPart set to the HumanoidRootPart by default.
- Static (usually Anchored) models which stay in one place unless a script explicitly moves them don't require a Model.PrimaryPart and tend not to benefit from having one set.
node_modules/@rbxts/types/include/generated/None.d.ts:22694
• WorldPivot: CFrame
This property determines where the pivot of a Model which does not have a set Model.PrimaryPart is located. If the Model does have a PrimaryPart, the pivot of the Model is equal to the pivot of that primary part instead, and this WorldPivot property is ignored.
For a newly created Model, its pivot will be treated as the center of the bounding box of its contents until the first time its Model.WorldPivot property is set. Once the world pivot is set for the first time, it is impossible to restore this initial behavior.
Most commonly, moving the model with the Studio tools, or with a model movement function such as PVInstance:PivotTo, Model:MoveTo, and Model:SetPrimaryPartCFrame will set the world pivot and thus end this new model behavior.
The purpose of this behavior is to allow Lua code to get a sensible pivot simply by creating a new model and parenting objects to it, avoiding the need to explicitly set Model.WorldPivot every time you create a model in code.
local model = Instance.new("Model") workspace.BluePart.Parent = model workspace.RedPart.Parent = model model.Parent = workspace
print(model:GetPivot()) -- Currently equal to the center of the bounding box containing "BluePart" and "RedPart"
model:PivotTo(CFrame.new(0, 10, 0) -- This works without needing to explicitly set "model.WorldPivot" Tags: NotReplicated
node_modules/@rbxts/types/include/generated/None.d.ts:22714
▸ BreakJoints(): void
Breaks connections between BaseParts, including surface connections with any adjacent parts, WeldConstraints, and all Welds and other JointInstances.
When BreakJoints is used on a Player character Model, the character's Humanoid will die as it relies on the Neck joint.
Note that although joints produced by surface connections with adjacent Parts can technically be recreated using Model:MakeJoints, this will only recreate joints produced by surfaces. Developers should not rely on this as following the joints being broken parts may no longer be in contact with each other.
void
node_modules/@rbxts/types/include/generated/None.d.ts:22722
▸ ClearAllChildren(): void
This function destroys all of an Instance's children.
As Instance:Destroy also calls itself on the children of an object it is used on, this function will destroy all descendants.
If the developer does not wish to destroy all descendants, they should use Instance:GetChildren or Instance:GetDescendants to loop through an object and select what to destroy. For example, the following code sample will destroy all parts in an object.
for _, instance in pairs(object:GetDescendants()) do if instance:IsA("BasePart") then instance:Destroy() end end
void
node_modules/@rbxts/types/include/generated/None.d.ts:537
▸ Clone<T>(): T
Clone creates a copy of an object and all of its descendants, ignoring all objects that are not Archivable. The copy of the root object is returned by this function and its Parent is set to nil.
If a reference property such as ObjectValue.Value is set in a cloned object, the value of the copy's property depends on original's value:
- If a reference property refers to an object that was also cloned, an internal reference, the copy will refer to the copy.
- If a reference property refers to an object that was not cloned, an external reference, the same value is maintained in the copy.
This function is typically used to create models that can be regenerated. First, get a reference to the original object. Then, make a copy of the object and insert the copy by setting its Parent to the Workspace or one of its descendants. Finally, when it's time to regenerate the model, Destroy the copy and clone a new one from the original like before.
| Name | Type |
|---|---|
T |
extends Instance<T> |
T
node_modules/@rbxts/types/include/generated/None.d.ts:548
▸ Destroy(): void
Sets the Instance.Parent property to nil, locks the Instance.Parent property, disconnects all connections and calls Destroy on all children. This function is the correct way to dispose of objects that are no longer required. Disposing of unneeded objects is important, since unnecessary objects and connections in a place use up memory (this is called a memory leak) which can lead to serious performance issues over time.
Tip: After calling Destroy on an object, set any variables referencing the object (or its descendants) to nil. This prevents your code from accessing anything to do with the object.
local part = Instance.new("Part") part.Name = "Hello, world" part:Destroy() -- Don't do this: print(part.Name) --> "Hello, world" -- Do this to prevent the above line from working: part = nil
Once an Instance has been destroyed by this method it cannot be reused because the Instance.Parent property is locked. To temporarily remove an object, set Parent it to nil instead. For example:
object.Parent = nil wait(2) object.Parent = workspace
To Destroy an object after a set amount of time, use Debris:AddItem.
void
node_modules/@rbxts/types/include/generated/None.d.ts:570
▸ FindFirstAncestor(name): undefined | Instance
Returns the first ancestor of the Instance whose Instance.Name is equal to the given name.
This function works upwards, meaning it starts at the Instance's immediate Instance.Parent and works up towards the DataModel. If no matching ancestor is found, it returns nil.
The following code snippet would find the first ancestor of the object named 'Car'.
local car = object:FindFirstAncestor("Car")
For variants of this function that find ancestors of a specific class, please see Instance:FindFirstAncestorOfClass and Instance:FindFirstAncestorWhichIsA.
| Name | Type |
|---|---|
name |
string |
undefined | Instance
ToolInstance.FindFirstAncestor
node_modules/@rbxts/types/include/generated/None.d.ts:582
▸ FindFirstAncestorOfClass<T>(className): undefined | Instances[T]
Returns the first ancestor of the Instance whose Instance.ClassName is equal to the given className.
This function works upwards, meaning it starts at the Instance's immediate Instance.Parent and works up towards the DataModel. If no matching ancestor is found, it returns nil.
A common use of this function is finding the Model a BasePart belongs to. For example:
local model = part:FindFirstAncestorOfClass("Model")
This function is a variant of Instance:FindFirstAncestor which checks the Instance.ClassName property rather than Instance.Name. Instance:FindFirstAncestorWhichIsA also exists, using the Instance:IsA method instead to respect class inheritance.
| Name | Type |
|---|---|
T |
extends keyof Instances
|
| Name | Type |
|---|---|
className |
T |
undefined | Instances[T]
ToolInstance.FindFirstAncestorOfClass
node_modules/@rbxts/types/include/generated/None.d.ts:594
▸ FindFirstAncestorWhichIsA<T>(className): undefined | Instances[T]
Returns the first ancestor of the Instance for whom Instance:IsA returns true for the given className.
This function works upwards, meaning it starts at the Instance's immediate Instance.Parent and works up towards the DataModel. If no matching ancestor is found, it returns nil.
Unlike Instance:FindFirstAncestorOfClass, this function uses Instance:IsA which respects class inheritance. For example:
print(part:IsA("Part")) --> true print(part:IsA("BasePart")) --> true print(part:IsA("Instance")) --> true
Therefore, the following code sample will return the first BasePart ancestor, regardless of if it is a WedgePart, MeshPart or Part.
local part = object:FindFirstAncestorWhichIsA("BasePart")
See also, Instance:FindFirstAncestor.
| Name | Type |
|---|---|
T |
extends keyof Instances
|
| Name | Type |
|---|---|
className |
T |
undefined | Instances[T]
ToolInstance.FindFirstAncestorWhichIsA
node_modules/@rbxts/types/include/generated/None.d.ts:612
▸ FindFirstChild(childName, recursive?): undefined | Instance
Returns the first child of the Instance found with the given name. If no child exists with the given name, this function returns nil. If the optional recursive argument is true, this function searches all descendants rather than only the immediate children of the Instance. Use this function if your code cannot guarantee the existence of an object with a given name.
FindFirstChild is necessary if you need to verify an object something exists before continuing. Attempting to index a child by name using the dot operator throws an error if the child doesn't exist.
-- The following line errors if Part doesn't exist in the Workspace: workspace.Part.Transparency = .5
Use FindFirstChild to first check for Part, then use an if-statement to run code that needs it.
local part = workspace:FindFirstChild("Part") if part then part.Transparency = .5 end
Sometimes the Name of an object is the same as that of a property of its Parent. When using the dot operator, properties take precedence over children if they share a name.
In the following example, a Folder called “Color” is added to a Part, which also has the Part/Color property. Part.Color refers to the Color3, not the Folder.
local part = Instance.new("Part") local folder = Instance.new("Folder") folder.Name = "Color" folder.Parent = part local c = part.Color --> A Color3 local c2 = part:FindFirstChild("Color") --> The Folder
A benefit of using FindFirstChild in this way is that the introduction of new properties does not impose a risk on your code.
Tip: If you only need to use the result of a FindFirstChild call once, such as getting the property of a child if it exists, you can use the following syntax with the and operator:
local myColor = workspace:FindFirstChild("SomePart") and workspace.SomePart.Color
If SomePart exists, myColor will contain the Color of SomePart. Otherwise, it'll be nil without throwing an error. This works due to short-circuiting: Lua ignores the right side if the left is nil/false
FindFirstChild takes about 20% longer than using dot operator, and almost 8 times longer than simply storing a reference to an object. Therefore, you should avoid calling FindFirstChild in performance dependent code, such as in tight loops or functions connected to RunService.Heartbeat/RunService.RenderStepped. Store the result in a variable, or consider using ChildAdded or WaitForChild to detect when a child of a given name becomes available.
| Name | Type |
|---|---|
childName |
string | number
|
recursive? |
boolean |
undefined | Instance
node_modules/@rbxts/types/include/generated/None.d.ts:658
▸ FindFirstChildOfClass<T>(className): undefined | Instances[T]
Returns the first child of the Instance whose ClassName is equal to the given className.
If no matching child is found, this function returns nil.
Unlike Instance:FindFirstChildWhichIsA this function uses only returns objects whose class matches the given className, ignoring class inheritance.
Developers looking for a child by name, should use Instance:FindFirstChild instead.
| Name | Type |
|---|---|
T |
extends keyof Instances
|
| Name | Type |
|---|---|
className |
T |
undefined | Instances[T]
ToolInstance.FindFirstChildOfClass
node_modules/@rbxts/types/include/generated/None.d.ts:668
▸ FindFirstChildWhichIsA<T>(className, recursive?): undefined | Instances[T]
Returns the first child of the Instance for whom Instance:IsA returns true for the given className.
If no matching child is found, this function returns nil. If the optional recursive argument is true, this function searches all descendants rather than only the immediate children of the Instance.
Unlike Instance:FindFirstChildOfClass, this function uses Instance:IsA which respects class inheritance. For example:
print(part:IsA("Part")) --> true print(part:IsA("BasePart")) --> true print(part:IsA("Instance")) --> true
Therefore, the following code sample will return the first BasePart child, regardless of if it is a WedgePart, MeshPart or Part.
local part = object:FindFirstChildWhichIsA("BasePart")
Developers looking for a child by name, should use Instance:FindFirstChild instead.
| Name | Type |
|---|---|
T |
extends keyof Instances
|
| Name | Type |
|---|---|
className |
T |
recursive? |
boolean |
undefined | Instances[T]
ToolInstance.FindFirstChildWhichIsA
node_modules/@rbxts/types/include/generated/None.d.ts:686
▸ FindFirstDescendant(name): undefined | Instance
| Name | Type |
|---|---|
name |
string |
undefined | Instance
ToolInstance.FindFirstDescendant
node_modules/@rbxts/types/include/generated/None.d.ts:691
▸ GetActor(): Actor
Actor
node_modules/@rbxts/types/include/generated/None.d.ts:692
▸ GetAttribute(attribute): unknown
This function returns the attribute which has been assigned to the given name. If no attribute has been assigned then nil is returned.
For example, the following code snippet will set the value of the instance's InitialPostion attribute. Note that this code sample does not define Instance:
local initialPosition = instance:GetAttribute("InitialPosition")
- Instance:SetAttribute, sets the attribute with the given name to the given value
- Instance:GetAttributes, returns a dictionary of string → variant pairs for each of the instance's attributes
- Instance.AttributeChanged, fires whenever an attribute is changed on the instance
- Instance:GetAttributeChangedSignal, returns an event that fires when the given attribute changes
| Name | Type |
|---|---|
attribute |
string |
unknown
node_modules/@rbxts/types/include/generated/None.d.ts:708
▸ GetAttributeChangedSignal(attribute): RBXScriptSignal<Callback>
This function returns an event that behaves exactly like the Changed event, except that the event only fires when the given attribute changes. It's generally a good idea to use this method instead of a connection to Changed with a function that checks the attribute name. Subsequent calls to this method on the same object with the same attribute name return the same event.
It is similar to Instance:GetPropertyChangedSignal but for attributes.
For example, the following code snippet will return a signal that fires the function Instance.AttributeChanged when the instance's InitialPosition attribute changes. Note that this code sample does not define Instance:
local function attributeChanged() print(“Attribute changed”) end
instance:GetAttributeChangedSignal("InitialPosition"):Connect(attributeChanged)
- Instance:SetAttribute, sets the attribute with the given name to the given value
- Instance:GetAttribute, returns the attribute which has been assigned to the given name
- Instance:GetAttributes, returns a dictionary of string → variant pairs for each of the instance's attributes
- Instance.AttributeChanged, fires whenever an attribute is changed on the instance
| Name | Type |
|---|---|
attribute |
string |
RBXScriptSignal<Callback>
ToolInstance.GetAttributeChangedSignal
node_modules/@rbxts/types/include/generated/None.d.ts:730
▸ GetAttributes(): object
This function returns a dictionary of string → variant pairs for each attribute where the string is the name of the attribute and the variant is a non-nil value.
For example, the following code snippet will print an instance's attributes and values. Note that this code sample does not define Instance:
local attributes = instance:GetAttributes() for name, value in pairs(attributes) do print(name .. “ “ .. value) end
- Instance:SetAttribute, sets the attribute with the given name to the given value
- Instance:GetAttribute, returns the attribute which has been assigned to the given name
- Instance.AttributeChanged, fires whenever an attribute is changed on the instance
- Instance:GetAttributeChangedSignal, returns an event that fires when the given attribute changes
object
node_modules/@rbxts/types/include/generated/None.d.ts:749
▸ GetBoundingBox(): LuaTuple<[CFrame, Vector3]>
This function returns a description of a volume that contains all BasePart children within a Model. The volume's orientation is based on the orientation of the PrimaryPart, and matches the selection box rendered in Studio when the model is selected. The description is provided in the form of a CFrame orientation and Vector3 size.
Mirroring the behavior of Terrain:FillBlock, it returns a CFrame representing the center of that bounding box and a Vector3 representing its size.
If there is no PrimaryPart for the model, the BoundingBox will be aligned to the world axes.
Pictured below is a Model with a pink semitransparent Part whose CFrame and Size have been set to the return values of this function called on the model.
local model = workspace.Model local part = workspace.Part local orientation, size = model:GetBoundingBox() part.Size = size part.CFrame = orientation
LuaTuple<[CFrame, Vector3]>
node_modules/@rbxts/types/include/generated/None.d.ts:22746
▸ GetChildren(): Instance[]
Returns an array (a numerically indexed table) containing all of the Instance's direct children, or every Instance whose Parent is equal to the object. The array can be iterated upon using either a numeric or generic for-loop:
-- Numeric for-loop example local children = workspace:GetChildren() for i = 1, #children do local child = children[i] print(child.Name .. " is child number " .. i) end-- Generic for-loop example local children = workspace:GetChildren() for i, child in ipairs(children) do print(child.Name .. " is child number " .. i) end
The children are sorted by the order in which their Parent property was set to the object.
See also the GetDescendants function.
Instance[]
node_modules/@rbxts/types/include/generated/None.d.ts:768
▸ GetDescendants(): Instance[]
The GetDescendants function of an object returns an array that contains all of the descendants of that object. Unlike Instance:GetChildren, which only returns the immediate children of an object, GetDescendants will find every child of the object, every child of those children, and so on and so forth.
The arrays returned by GetDescendants are arranged so that parents come earlier than their children. For example, let's look at the following setup:
Here we have a Model in the Workspace. Inside this model is three parts (C, D, and E) and another model (InnerModel). Inside the inner model are two more parts (A and B). If we use GetDescendants on the first model and print out the contents of the returned array, we can see that the first level of children, InnerModel, C, D, and E, are printed out before A and B.
local descendants = game.Workspace.Model:GetDescendants()
-- Loop through all of the descendants of the model and -- print out their name for index, descendant in pairs(descendants) do print(descendant.Name) end
-- Prints: -- C -- D -- E -- InnerModel -- A -- B Tags: CustomLuaState
Instance[]
node_modules/@rbxts/types/include/generated/None.d.ts:795
▸ GetExtentsSize(): Vector3
Returns the size of the smallest bounding box that contains all of the BaseParts in the Model. If Model.PrimaryPart exists then the bounding box will be aligned to that part. If a primary part has not been set then the function will chose a part in the model to align the bounding box to. As the the selection of this part is not deterministic it is recommended to set a Model.PrimaryPart to get consistent results with this function.
Note this function only returns the size of the smallest bounding box, and the developer must employ their own method to obtain the position of the bounding box.
Vector3
node_modules/@rbxts/types/include/generated/None.d.ts:22752
▸ GetFullName(): string
Returns a string describing the Instance's ancestry. The string is a concatenation of the Name of the object and its ancestors, separated by periods. The DataModel (game) is not considered. For example, a Part in the Workspace may return Workspace.Part.
When called on an Instance that is not a descendant of the DataModel, this function considers all ancestors up to and including the topmost one without a Parent.
This function is useful for logging and debugging. You shouldn't attempt to parse the returned string for any useful operation; this function does not escape periods (or any other symbol) in object names. In other words, although its output often appears to be a valid Lua identifier, it is not guaranteed.
string
node_modules/@rbxts/types/include/generated/None.d.ts:803
▸ GetModelCFrame(): CFrame
This value historically returned the CFrame of a central position in the model. It has been deprecated as it did not provide reliable results. Tags: Deprecated
deprecated
CFrame
node_modules/@rbxts/types/include/generated/None.d.ts:22758
▸ GetModelSize(): Vector3
The GetModelSize function returns the Vector3 size of the Model.
Tags: Deprecated
deprecated
Vector3
node_modules/@rbxts/types/include/generated/None.d.ts:22764
▸ GetPivot(): CFrame
This function gets the pivot of a PVInstance. This is often used with PVInstance:PivotTo to move a model.
Models and BaseParts are both PVInstances (“Position Velocity Instances”) and so both have this function.
CFrame
node_modules/@rbxts/types/include/generated/None.d.ts:20873
▸ GetPrimaryPartCFrame(): CFrame
This function has been superseded by PVInstance:GetPivot which acts as a replacement and does not change your code's behavior. Use PVInstance:GetPivot for new work and migrate your existing Model:GetPrimaryPartCFrame calls when convenient.
Returns the CFrame of the Model's Model.PrimaryPart.
This function is equivalent to the following.
Model.PrimaryPart.CFrameNote this function will throw an error if no primary part exists for the Model. If this behavior is not desired developers can do the following, which will be equal to nil if there is no primary part.
local cFrame = Model.PrimaryPart and Model.PrimaryPart.CFrameCFrame
ToolInstance.GetPrimaryPartCFrame
node_modules/@rbxts/types/include/generated/None.d.ts:22782
▸ GetPropertyChangedSignal<T>(propertyName): RBXScriptSignal<fn>
This method returns an event that behaves exactly like the Changed event, except that the event only fires when the given property changes. It's generally a good idea to use this method instead of a connection to Changed with a function that checks the property name. Subsequent calls to this method on the same object with the same property name return the same event.
print(object:GetPropertyChangedSignal("Name") == object:GetPropertyChangedSignal("Name")) --> always true
ValueBase objects, such as IntValue and StringValue, use a modified Changed event that fires with the contents of the Value property. As such, this method provides a way to detect changes in other properties of those objects. For example, to detect changes in the Name property of an IntValue, use IntValue:GetPropertyChangedSignal("Name"):Connect(someFunc) since the Changed event of IntValue objects only detect changes on the Value property.
| Name | Type |
|---|---|
T |
extends Instance<T> |
| Name | Type |
|---|---|
propertyName |
Exclude<ExcludeKeys<T, symbol | Callback | RBXScriptSignal<Callback>>, "Changed"> |
RBXScriptSignal<fn>
ToolInstance.GetPropertyChangedSignal
node_modules/@rbxts/types/include/generated/None.d.ts:811
▸ IsA<T>(className): this is Instances[T]
IsA returns true if the Instance's class is equivalent to or a subclass of a given class. This function is similar to the instanceof operators in other languages, and is a form of type introspection. To ignore class inheritance, test the ClassName property directly instead. For checking native Lua data types (number, string, etc) use the functions type and typeof.
Most commonly, this function is used to test if an object is some kind of part, such as Part or WedgePart, which inherits from BasePart (an abstract class). For example, if your goal is to change all of a Character's limbs to the same color, you might use GetChildren to iterate over the children, then use IsA to filter non-BasePart objects which lack the BrickColor property:
local function paintFigure(character, color) -- Iterate over the child objects of the character for _, child in pairs(character:GetChildren()) do -- Filter out non-part objects, such as Shirt, Pants and Humanoid -- R15 use MeshPart and R6 use Part, so we use BasePart here to detect both: if child:IsA("BasePart") then child.BrickColor = color end end end paintFigure(game.Players.Player.Character, BrickColor.new("Bright blue"))
Since all classes inherit from Instance, calling object:IsA("Instance") will always return true.
Tags: CustomLuaState
| Name | Type |
|---|---|
T |
extends keyof Instances
|
| Name | Type |
|---|---|
className |
T |
this is Instances[T]
node_modules/@rbxts/types/include/generated/None.d.ts:835
▸ IsAncestorOf(descendant): boolean
Returns true if an Instance is an ancestor of the given descendant.
An Instance is considered the ancestor of an object if the object's Instance.Parent or one of it's parent's Instance.Parent is set to the Instance.
See also, Instance:IsDescendantOf.
| Name | Type |
|---|---|
descendant |
Instance |
boolean
node_modules/@rbxts/types/include/generated/None.d.ts:843
▸ IsDescendantOf(ancestor): boolean
Returns true if an Instance is a descendant of the given ancestor.
An Instance is considered the descendant of an object if the Instance's parent or one of its parent's parent is set to the object.
Note, DataModel is a descendant of nil. This means IsDescendantOf cannot be used with a parameter of nil to check if an object has been removed.
See also, Instance:IsAncestorOf.
| Name | Type |
|---|---|
ancestor |
Instance |
boolean
node_modules/@rbxts/types/include/generated/None.d.ts:853
▸ MakeJoints(): void
Deprecated
SurfaceType based joining is deprecated, do not use MakeJoints for new projects. WeldConstraints and HingeConstraints should be used instead
Goes through all Parts in the Model and creates joints between the specified Parts and any planar touching surfaces, depending on the parts' surfaces.
- Smooth surfaces will not create joints
- Glue surfaces will create a Glue joint
- Weld will create a Weld joint with any surface except for Unjoinable
- Studs, Inlet, or Universal will each create a Snap joint with either of other the other two surfaces (e.g. Studs with Inlet and Universal)
- Hinge and Motor surfaces create Rotate and RotateV joint instances
This function will not work if the Part is not a descendant of Workspace. Therefore developers must first ensure the Model is parented to Workspace before using MakeJoints.
void
node_modules/@rbxts/types/include/generated/None.d.ts:22798
▸ MoveTo(position): void
Moves the Model.PrimaryPart to the given position. If a primary part has not been specified then the root part of the model will be used. Because the root part is not deterministic, it is recommended to always set a Model.PrimaryPart when using MoveTo.
If there are any obstructions where the model is to be moved to, such as Terrain or other BaseParts, then the model will be moved up in the Y direction until there is nothing in the way. If this behavior is not desired, Model:SetPrimaryPartCFrame should be used instead.
Note that rotation is not preserved when moving a model with MoveTo. It is recommended to use either Model:TranslateBy or Model:SetPrimaryPartCFrame if the current rotation of the model needs to be preserved.
| Name | Type |
|---|---|
position |
Vector3 |
void
node_modules/@rbxts/types/include/generated/None.d.ts:22806
▸ PivotTo(targetCFrame): void
Transforms the PVInstance along with all of its descendant PVInstances such that the pivot is now located at the specified CFrame. This is the primary function that should be used to move Models via scripting.
BaseParts are moved in this way by having their CFrame transformed by the necessary offset. Models are moved in this way by having their Model.WorldPivot transformed by the necessary offset.
Note that for efficiency purposes, Instance.Changed events are not fired for Position and Orientation of BaseParts moved in this way; they are only fired for CFrame.
When calling PivotTo on Models, the offsets of the descendant parts and models are cached, such that subsequent calls to PivotTo on the same model do not accumulate floating point drift between the parts making up the model.
Models and BaseParts are both PVInstances (“Position Velocity Instances”) and so both have this function.
| Name | Type |
|---|---|
targetCFrame |
CFrame |
void
node_modules/@rbxts/types/include/generated/None.d.ts:20885
▸ ResetOrientationToIdentity(): void
Resets the rotation of the model's parts to the previously set identity rotation, which is done through the Model:SetIdentityOrientation method. Tags: Deprecated
deprecated
void
ToolInstance.ResetOrientationToIdentity
node_modules/@rbxts/types/include/generated/None.d.ts:22812
▸ SetAttribute(attribute, value): void
This function sets the attribute with the given name to the given value. If the value given is nil, then the attribute will be removed (since nil is returned by default).
For example, the following code snippet will set the instance's InitialPosition attribute to DataType/Vector3|Vector3.new(0, 0, 0). Note that this code sample does not define Instance:
instance:SetAttribute("InitialPosition", Vector3.new(0, 0, 0))
Naming requirements and restrictions:
- Names must only use alphanumeric characters and underscore
- No spaces or unique symbols are allowed
- Strings must be 100 characters or less
- Names are not allowed to start with RBX unless the caller is a Roblox core-script (reserved for Roblox)
When attempting to set an attribute to an unsupported type, an error will be thrown.
- Instance:GetAttribute, returns the attribute which has been assigned to the given name
- Instance:GetAttributes, returns a dictionary of string → variant pairs for each of the instance's attributes
- Instance.AttributeChanged, fires whenever an attribute is changed on the instance
- Instance:GetAttributeChangedSignal, returns an event that fires when the given attribute changes
| Name | Type |
|---|---|
attribute |
string |
value |
unknown |
void
node_modules/@rbxts/types/include/generated/None.d.ts:881
▸ SetIdentityOrientation(): void
Sets the identity rotation of the given model, allowing you to reset the rotation of the entire model later, through the use of the ResetOrientationToIdentity method.
Tags: Deprecated
deprecated
void
ToolInstance.SetIdentityOrientation
node_modules/@rbxts/types/include/generated/None.d.ts:22818
▸ SetPrimaryPartCFrame(cframe): void
This function has been superseded by PVInstance:PivotTo which acts as a more performant replacement and does not change your code's behavior. Use PVInstance:PivotTo for new work and migrate your existing Model:SetPrimaryPartCFrame calls when convenient.
Sets the BasePart.CFrame of the Model's Model.PrimaryPart. All other parts in the model will also be moved and will maintain their orientation and offset respective to the Model.PrimaryPart.
Note, this function will throw an error if no Model.PrimaryPart exists for the model. This can cause issues if, for example, the primary part was never set or has been destroyed. Therefore, it is recommended the developer check the Model.PrimaryPart exists before using this function. For example:
if model.PrimaryPart then
model:SetPrimaryPartCFrame(cf)
endA common use for this is for the 'teleportation' of player characters to different positions.
| Name | Type |
|---|---|
cframe |
CFrame |
void
ToolInstance.SetPrimaryPartCFrame
node_modules/@rbxts/types/include/generated/None.d.ts:22834
▸ TranslateBy(delta): void
Shifts a Model by the given Vector3 offset, preserving the Model's orientation. If another BasePart or Terrain already exists at the new position then the Model will overlap said object.
The translation is applied in world space rather than object space, meaning even if the model's parts are orientated differently it will still move along the standard axis.
| Name | Type |
|---|---|
delta |
Vector3 |
void
node_modules/@rbxts/types/include/generated/None.d.ts:22840
▸ WaitForChild(childName): Instance
Returns the child of the Instance with the given name. If the child does not exist, it will yield the current thread until it does.
If the timeOut parameter is specified, this function will return nil and time out after timeOut seconds elapsing without the child being found.
WaitForChild is extremely important when working on code ran by the client (in a LocalScript). Roblox does not guarantee the time or order in which objects are replicated from the server to the client. This can cause scripts to break when indexing objects that do not exist yet.
For example, a LocalScript may access a Model in the Workspace called 'Ship' like so:
local ship = workspace.Ship -- Will error if ship hasn't replicated
However if the model 'Ship' has not replicated to the client when this code is ran an error will be returned breaking the LocalScript.
Another alternative is using Instance:FindFirstChild. Not only is this good practice when indexing objects in the DataModel (as it avoids accidentally accessing properties) but it does not break if the object does not exist. For example:
local ship = workspace:FindFirstChild("Ship") -- Won't error, but ship will be nil if the ship hasn't replicated
Here, if the model doesn't exist the code will not error. Instead the value ship will be equal to nil. This is better, but still not much good if we want to use the ship model.
Instead WaitForChild should be used:
local ship = workspace:WaitForChild("Ship") -- Will wait until the ship has replicated before continuing
Here, the thread will be yielded until the ship model has been found. This means the ship model can be used as soon as it is ready.
- If a call to this function exceeds 5 seconds without returning, and no timeOut parameter has been specified, a warning will be printed to the output that the thread may yield indefinitely; this warning takes the form
Infinite yield possible on 'X:WaitForChild("Y")', where X is the parent name and Y is the child object name. - This function does not yield if a child with the given name exists when the call is made.
- This function is less efficient than Instance:FindFirstChild or the dot operator. Therefore, it should only be used when the developer is not sure if the object has replicated to the client. Generally this is only the first time the object is accessed Tags: CustomLuaState, CanYield
| Name | Type |
|---|---|
childName |
string | number
|
Instance
node_modules/@rbxts/types/include/generated/None.d.ts:921
▸ WaitForChild(childName, timeOut): undefined | Instance
| Name | Type |
|---|---|
childName |
string | number
|
timeOut |
number |
undefined | Instance
node_modules/@rbxts/types/include/generated/None.d.ts:922
- client/controllers/SpringCam
- client/controllers/Direction
- client/controllers/Rotation
- client/controllers/Shake
- client/controllers/Input
- server/modules/InputParser
- server/modules/Middleware
- server/modules/AnimPlayer
- server/modules/Action
- server/modules/Defer


