主题
LocalScript
概览
| 字段 | 值 |
|---|---|
| Kind | Unit · 单位 Unit |
| Realm | common |
LocalScript,继承自 BaseScript(1 属性)。
继承关系
- Unit(4 属性 / 25 函数 / 6 事件)
- BaseScript(1 属性)
- [LocalScript]
- BaseScript(1 属性)
继承成员
2 个来源 / 5 属性 / 25 函数 / 6 事件
- 来自 BaseScript(1 属性)
- 属性:
SourceCode
- 属性:
- 来自 Unit(4 属性 / 25 函数 / 6 事件)
- 属性:
AssetId、Name、Desc、Parent - 函数:
ClearAllChildren、GetChildren、GetDescendants、IsAncestorOf、IsDescendantOf、FindFirstAncestor、FindFirstAncestorWhichIsA、FindFirstAncestorOfClass、FindFirstChild、FindFirstChildWhichIsA、FindFirstChildOfClass、HasChildren、GetChildCount、GetChildAtIndex、SetAttribute、GetAttribute、GetAllProps、Clone、IsA、Destroy、GetPropertyChangedSignal、GetAttributeChangedSignal、FindFromPath、GetFullPath、GetDebugId - 事件:
ChildAdded、ChildRemoved、DescendantAdded、DescendantRemoving、AncestryChanged、Destroying
- 属性:
本地脚本,仅在本地客户端生效
代码示例
创建 LocalScript 实例
lua
-- @runtime client
local World = game:GetService('World')
local localScript = World:CreateUnit('LocalScript', {})
print('LocalScript 已创建:', localScript.Name)