Update nexus wiki content

This commit is contained in:
2026-05-03 05:42:06 +08:00
parent 90f3811b83
commit 111bc65b7b
707 changed files with 32306 additions and 7289 deletions

View File

@@ -1,55 +1,76 @@
---
title: "Roblox Systems Scripter Agent Personality"
type: source
tags: [roblox, game-development, luau, client-server, datastore, security]
date: 2026-04-26
tags: []
date: 2026-05-01
---
## Source File
- [[raw/Agent/agency-agents/game-development/roblox-studio/roblox-systems-scripter.md]]
- [[Agent/agency-agents/game-development/roblox-studio/roblox-systems-scripter.md]]
## Summary用中文描述
- 核心主题Roblox 平台工程专家 Agent 人格定义,专注于 Luau 语言下的服务器权威架构与安全实现
- 问题域:如何构建可扩展、防作弊、持久化数据安全的 Roblox 游戏体验
- 方法/机制服务器权威模型、RemoteEvent/RemoteFunction 安全验证DataStore 重试与双保存机制、ModuleScript 模块化架构
- 结论/价值:提供一套完整的 Roblox 系统脚本工程规范,涵盖从基础架构设计到高级并行 Luau 优化的全链路最佳实践
- 核心主题Roblox Systems Scripter Agent——Roblox 平台系统工程专家 AI Agent 人格规范,专精 Luau 编程、客户端-服务器安全模型、RemoteEvent/RemoteFunction 通信架构、DataStore 持久化与模块化代码组织。
- 问题域:如何在 Roblox 平台构建安全、可扩展、数据可靠的多人游戏系统;如何正确划分客户端与服务器的职责边界;如何防止客户端 exploit 攻击;如何设计可维护的模块化代码架构。
- 方法/机制:服务器权威模型Server-Authoritative、RemoteEvent/RemoteFunction 安全验证链路、pcall + 指数退避重试的 DataStore 封装、ModuleScript 分层架构ServerStorage/ReplicatedStorage/StarterPlayerScripts、并行 Luau 与 Actor 模型、内存优化与对象池化。
- 结论/价值:Roblox 游戏系统的核心原则是"服务器即真相"——客户端只能请求动作所有状态变更和验证必须在服务器执行DataStore 必须用 pcall 保护并实现重试逻辑;所有游戏逻辑应封装在 ModuleScript 中实现可测试性和复用性。
## Key Claims用中文描述
- 服务器是唯一的真相来源:客户端只接收视觉确认,不拥有任何游戏状态
- 客户端通过 RemoteEvent/RemoteFunction 发送的请求,服务器必须重新验证,不能信任
- DataStore 操作必须用 `pcall`并实现指数退避重试,防止数据损坏
- 玩家数据必须在 `PlayerRemoving``game:BindToClose()` 两处保存,缺一不可
- 所有游戏系统必须放在 ModuleScript 中Script/LocalScript 仅做引导,不含核心逻辑
- 客户端-服务器安全模型:服务器是真相的唯一来源——客户端展示状态,不拥有状态;所有游戏状态变更(伤害、货币、物品)只能在服务器执行。
- RemoteEvent 安全规范FireServer() 客户端→服务器请求必须经过服务器端验证FireClient() 服务器→客户端安全RemoteFunction:InvokeClient() 绝对不能在服务器调用(恶意客户端可永久阻塞服务器线程)。
- DataStore 可靠性DataStore 调用必须用 pcall 包并实现指数退避重试;保存时机为 PlayerRemoving 和 BindToClose 双重保护;写入频率不超过每 6 秒一次。
- 模块化架构原则:所有游戏系统必须是 ModuleScript由服务器 Script 或客户端 LocalScript 引用;模块返回表或类,禁止返回 nil共享常量放在 ReplicatedStorage 模块。
- 并行 Luau 性能优化:使用 task.desynchronize() 实现并行计算Actor 模型支持真正并行脚本执行SharedTable 用于跨 Actor 数据共享debug.profilebegin/profileend 验证性能收益。
- 内存与性能管理:使用 GetPartBoundsInBox 空间查询替代遍历;对象池化复用效果和 NPC使用 Destroy() 而非 Parent=nil 防止内存泄漏。
## Key Quotes
> "Clients request, servers decide. That health change belongs on the server." — 客户端-服务器信任边界原则
> "That save has no `pcall` — one DataStore hiccup corrupts the player's data permanently" — DataStore 安全核心警示
> "RemoteFunction:InvokeClient() from the server — a malicious client can yield the server thread forever" — 危险操作警示
> "The server is truth — clients display state, they do not own it" — 客户端-服务器安全模型核心原则
> "Never trust data sent from a client via RemoteEvent/RemoteFunction without server-side validation" — 客户端数据验证铁律
> "That save has no pcall — one DataStore hiccup corrupts the player's data permanently" — DataStore 安全意识沟通风格
> "All game systems are ModuleScripts required by server-side Scripts or client-side LocalScripts — no logic in standalone Scripts/LocalScripts beyond bootstrapping" — 模块化架构规范
> "RemoteFunction:InvokeClient() never called from server — zero yielding server thread risk" — 成功指标之一
## Key Concepts
- [[Server-Authoritative Architecture]]:服务器权威模型——所有游戏逻辑状态由服务器拥有,客户端只显示状态,不决定状态
- [[RemoteEvent Security]]RemoteEvent 安全模式——FireServer 请求需在服务器端完整验证,不能信任客户端数据
- [[DataStore Reliability]]DataStore 可靠性模式——pcall 包装 + 指数退避重试 + 双保存点PlayerRemoving + BindToClose
- [[ModuleScript Architecture]]ModuleScript 架构规范——所有逻辑放入 ModuleScript 返回表Script/LocalScript 仅 bootstrap
- [[Parallel Luau]]:并行 Luau——使用 task.desynchronize() 和 Actor 模型实现真正的多线程脚本执行
- [[Object Pooling]]:对象池模式——预实例化 effects 和 NPC减少 GC 压力
- [[UpdateAsync Atomic Pattern]]UpdateAsync 原子写入——处理并发写入冲突,比 SetAsync 更安全
- [[ServerAuthoritativeModel]]:服务器权威模型——所有游戏逻辑服务器执行,客户端仅接收结果和显示视觉反馈
- [[RemoteEvent]]Roblox 跨客户端-服务器通信机制FireServer()(客户端→服务器)和 FireClient()(服务器→客户端
- [[RemoteFunction]]Roblox 远程函数调用InvokeServer() 和 InvokeClient(),后者存在线程阻塞风险
- [[DataStore]]Roblox 玩家数据持久化服务;必须用 pcall 保护,支持指数退避重试
- [[ModuleScript]]Luau 模块系统;封装游戏逻辑,返回表或类,被 Script/LocalScript require 调用
- [[ParallelLuau]]:并行 Luau使用 task.desynchronize() 和 Actor 模型实现多线程计算
- [[ObjectPooling]]:对象池化;预实例化效果和 NPC减少运行时实例创建开销
- [[ServiceLocator]]:服务定位器模式;中央注册表实现依赖注入
- [[FeatureFlags]]:功能开关;通过 ReplicatedStorage 配置对象控制功能启用/禁用
- [[ActorModel]]Actor 模型;每个 Actor 在独立线程运行脚本SharedTable 实现跨 Actor 数据安全共享
- [[UpdateAsync]]DataStore 原子更新方法;比 SetAsync 更安全地处理并发写入冲突
- [[SessionLocking]]:会话锁定;防止同一玩家同时在两台服务器加载造成数据损坏
## Key Entities
- [[Roblox]]:游戏开发平台,提供 Roblox Studio、Lua 变体 Luau、DataStore 服务
- [[Luau]]Roblox 的脚本语言,是 Lua 的类型安全变体
- [[DataStoreService]]Roblox 数据持久化服务,用于保存玩家数据到云端
- [[ReplicatedStorage]]Roblox 实例容器RemoteEvent 存放位置,客户端和服务器均可访问
- [[ServerStorage]]Roblox 实例容器,仅服务器可访问,用于存放核心模块
- [[RobloxSystemsScripter]]Roblox 平台系统工程专家 AI Agent安全优先、架构严谨、平台精通、性能敏感
- [[RobloxPlatform]]Roblox 游戏开发平台Luau 编程语言、客户端-服务器执行模型、DataStore 持久化
- [[Luau]]Roblox 专用的 Luau 编程语言(基于 Lua强类型注解、协程任务系统
- [[DataStoreService]]Roblox 数据存储服务;玩家数据持久化,支持 GetAsync/SetAsync/UpdateAsync
- [[ReplicatedStorage]]Roblox 服务;存储客户端和服务器共享的模块、远程事件、常量
- [[ServerStorage]]Roblox 服务;仅服务器可访问,用于存储服务器端模块和游戏数据
- [[Players]]Roblox 服务;管理所有玩家实例,提供 PlayerAdded/PlayerRemoving 生命周期事件
- [[BindableEvent]]Roblox 绑定事件;服务器内部模块间通信,解耦事件发布-订阅
## Connections
- [[Roblox Experience Designer]] ← extends ← [[Roblox Systems Scripter]]
- [[Server-Authoritative Architecture]] ← foundational ← [[RemoteEvent Security]]
- [[DataStore Reliability]] ← depends_on ← [[Server-Authoritative Architecture]]
- [[RobloxExperienceDesigner]] ← extends ← [[RobloxSystemsScripter]]
- [[RobloxSystemsScripter]] ← depends_on ← [[DataStoreService]]
- [[RobloxSystemsScripter]] ← depends_on ← [[Luau]]
- [[RobloxSystemsScripter]] ← depends_on ← [[ServerAuthoritativeModel]]
- [[RobloxSystemsScripter]] ← uses ← [[ModuleScript]]
- [[RobloxSystemsScripter]] ← uses ← [[RemoteEvent]]
- [[RobloxSystemsScripter]] ← uses ← [[ParallelLuau]]
- [[RobloxSystemsScripter]] ← uses ← [[DataStore]]
## Contradictions
- 与 [[Unity Architect]] 冲突
- 冲突点:客户端预测Client Prediction策略
- 当前观点Roblox Systems Scripter 建议简化场景下不做本地预测,所有状态由服务器驱动
- 对方观点Unity Multiplayer Engineer 建议使用服务器回滚式 client prediction 提升响应体验
- 说明两者平台不同Roblox 的 RemoteEvent 架构天然适合服务器权威Unity 的 Photon/Netcode 支持更灵活的预测策略
- 与 [[UnrealMultiplayerArchitect]] 的权威模型差异
- 冲突点:客户端预测与服务器权威的关系
- 当前观点RobloxSystemsScripter):服务器完全权威,客户端只展示状态,无本地预测
- 对方观点UnrealMultiplayerArchitect允许客户端预测以提升网络响应性配合服务器校正
- 背景Roblox 的 Luau 执行模型和 Unity/Unreal 的 C++ 网络模型架构假设不同Roblox 平台强制服务器权威是为了防止 exploit但牺牲了网络响应速度Unreal/Unity 在 C++ 层有更细粒度的网络同步控制
- 与 [[UnityMultiplayerEngineer]] 的帧率同步差异:
- 冲突点:帧率权威归属
- 当前观点RobloxSystemsScripterRoblox 引擎内置物理同步,开发者只需关注 RemoteEvent 验证
- 对方观点UnityMultiplayerEngineer需要手动实现帧率同步和状态插值
- 背景Roblox 是封闭平台,物理引擎由 Roblox 统一管理Unity 是开源引擎,物理同步由开发者实现