File tree Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Expand file tree Collapse file tree 2 files changed +14
-13
lines changed Original file line number Diff line number Diff line change @@ -291,14 +291,19 @@ local clone = table.clone(original)
291291To copy a more complex table with nested tables inside it, you'll need to use a recursive function similar to the following:
292292
293293``` lua
294- local function deepCopy (original )
294+ -- The function used for deep copying a table
295+ local function deepCopy (original )
296+ -- Define the new table for the copy
295297 local copy = {}
296- for k , v in pairs (original ) do
297- if type (v ) == " table" then
298- v = deepCopy (v )
299- end
300- copy [k ] = v
298+
299+ -- Loop through the original table to clone
300+ for key , value in original do
301+ -- If the type of the value is a table, deep copy it to the key (index)
302+ -- Else (or) the type isn't a table, assign the default value to the index instead
303+ copy [key ] = type (value ) == " table" and deepCopy (value ) or value
301304 end
305+
306+ -- Return the finalized copy of the deep cloned table
302307 return copy
303308end
304309```
Original file line number Diff line number Diff line change @@ -94,14 +94,10 @@ properties:
9494 summary : |
9595 Stores the tool's "grip" properties as one `Datatype.CFrame`.
9696 description : |
97- The Grip property stores the tool's "grip" properties as a single
97+ The ` Grip` property stores the tool's "grip" properties as a single
9898 `Datatype.CFrame`. These properties position how the player holds the tool
99- and include `GripUp`, `GripRight`, `GripForward`, and `GripPos`.
100-
101- Unlike the grip properties that it stores, this consolidated property
102- doesn't appear in the [Properties](../../../studio/properties.md) window
103- in Studio. Regardless, you can set and get it from a `Class.Script` or
104- `Class.LocalScript`.
99+ and include `Class.Tool.GripUp|GripUp`, `Class.Tool.GripRight|GripRight`,
100+ `Class.Tool.GripForward|GripForward`, and `Class.Tool.GripPos|GripPos`.
105101 code_samples :
106102 - grip-stick
107103 type : CFrame
You can’t perform that action at this time.
0 commit comments