Files
nexus/wiki/sources/roblox-systems-scripter.md
2026-04-26 12:02:53 +08:00

56 lines
3.8 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
---
title: "Roblox Systems Scripter Agent Personality"
type: source
tags: [roblox, game-development, luau, client-server, datastore, security]
date: 2026-04-26
---
## Source File
- [[raw/Agent/agency-agents/game-development/roblox-studio/roblox-systems-scripter.md]]
## Summary用中文描述
- 核心主题Roblox 平台工程专家的 Agent 人格定义,专注于 Luau 语言下的服务器权威架构与安全实现
- 问题域:如何构建可扩展、防作弊、持久化数据安全的 Roblox 游戏体验
- 方法/机制服务器权威模型、RemoteEvent/RemoteFunction 安全验证、DataStore 重试与双保存机制、ModuleScript 模块化架构
- 结论/价值:提供一套完整的 Roblox 系统脚本工程规范,涵盖从基础架构设计到高级并行 Luau 优化的全链路最佳实践
## Key Claims用中文描述
- 服务器是唯一的真相来源:客户端只接收视觉确认,不拥有任何游戏状态
- 客户端通过 RemoteEvent/RemoteFunction 发送的请求,服务器必须重新验证,不能信任
- DataStore 操作必须用 `pcall` 包装并实现指数退避重试,防止数据损坏
- 玩家数据必须在 `PlayerRemoving``game:BindToClose()` 两处保存,缺一不可
- 所有游戏系统必须放在 ModuleScript 中Script/LocalScript 仅做引导,不含核心逻辑
## 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" — 危险操作警示
## 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 更安全
## Key Entities
- [[Roblox]]:游戏开发平台,提供 Roblox Studio、Lua 变体 Luau、DataStore 服务
- [[Luau]]Roblox 的脚本语言,是 Lua 的类型安全变体
- [[DataStoreService]]Roblox 数据持久化服务,用于保存玩家数据到云端
- [[ReplicatedStorage]]Roblox 实例容器RemoteEvent 存放位置,客户端和服务器均可访问
- [[ServerStorage]]Roblox 实例容器,仅服务器可访问,用于存放核心模块
## Connections
- [[Roblox Experience Designer]] ← extends ← [[Roblox Systems Scripter]]
- [[Server-Authoritative Architecture]] ← foundational ← [[RemoteEvent Security]]
- [[DataStore Reliability]] ← depends_on ← [[Server-Authoritative Architecture]]
## Contradictions
- 与 [[Unity Architect]] 冲突:
- 冲突点客户端预测Client Prediction策略
- 当前观点Roblox Systems Scripter 建议简化场景下不做本地预测,所有状态由服务器驱动
- 对方观点Unity Multiplayer Engineer 建议使用服务器回滚式 client prediction 提升响应体验
- 说明两者平台不同Roblox 的 RemoteEvent 架构天然适合服务器权威Unity 的 Photon/Netcode 支持更灵活的预测策略