YouTube2Text

How client-server architecture works on Roblox — Transcript

by Roblox Creators · 1,716 words · 274 segments · language en · Watch on YouTube

Full transcript

  1. 0:00This video is for developers who have
  2. 0:01experience with other game engines, but
  3. 0:03are new to Roblox. If you've used other
  4. 0:06engines, adapting to Roblox's
  5. 0:07client-server architecture can require
  6. 0:09[music] a bit of a shift in mindset.
  7. 0:11Let's discuss why.
  8. 0:13Hey everyone, it's Andrew from Roblox.
  9. 0:15What I have here is a demo experience
  10. 0:17generously provided by Mr. Chicken
  11. 0:19Rocket and Dev Odysseus. It's a
  12. 0:21twin-stick shooter, a genre that I
  13. 0:22imagine many of you are familiar with.
  14. 0:24You shoot skeletons with friends, revel
  15. 0:26in the chaos, and grab gems. Let's dig
  16. 0:29into some key features of this
  17. 0:30experience, and along the way we can
  18. 0:32talk more broadly about developing on
  19. 0:33Roblox. It's a lot. I want to cover a
  20. 0:36lot. We'll talk about the following.
  21. 0:42Let's start [music] with project
  22. 0:43architecture. The first, maybe most
  23. 0:45important point to understand when
  24. 0:47getting started with Roblox is that the
  25. 0:48client-server architecture means that
  26. 0:50the server owns everything. As you build
  27. 0:54in Studio, what you're looking at is the
  28. 0:56server's view of the world. [music] The
  29. 0:57client then gets some subset of that
  30. 1:00view depending on the situation, and can
  31. 1:02make its own local-only changes for
  32. 1:03things like the user interface and
  33. 1:05visual effects. [music]
  34. 1:07This architecture means there are a
  35. 1:09whole bunch of places to put scripts. We
  36. 1:11have not one, but two other videos on
  37. 1:13this subject. Check them out if you want
  38. 1:15to get into the nitty-gritty. The basics
  39. 1:17are that server scripts go in server
  40. 1:19script service, and client scripts go
  41. 1:21[music] in replicated storage with a run
  42. 1:23context of client. Shared module scripts
  43. 1:26also go in replicated storage.
  44. 1:28As we switch between the client and the
  45. 1:30server in Studio, you can see right away
  46. 1:32that the contents of server script
  47. 1:34service and server storage just aren't
  48. 1:36on the client. The difference is even
  49. 1:38more stark if you test an experience
  50. 1:40that uses streaming and enable the free
  51. 1:42cam with shift P. In addition to not
  52. 1:44having everything you saw on the server
  53. 1:46while editing the experience, [music]
  54. 1:48you can see here that the client only
  55. 1:49has a subset of the whole workspace.
  56. 1:51When we start building, the first step
  57. 1:53is to give ourselves some objects to
  58. 1:55[music] work with. Mr. Chicken Rocket
  59. 1:57calls this mental scaffolding, a term I
  60. 1:59love, but the more prosaic way to think
  61. 2:01about it is that games are all about
  62. 2:03interactivity,
  63. 2:04>> [music]
  64. 2:04>> and it's hard to add interactivity to
  65. 2:06objects that don't exist. If you want to
  66. 2:08build a twin-stick shooter with a
  67. 2:10procedural layout and destructible
  68. 2:11objects, the first step is to build some
  69. 2:14rooms.
  70. 2:15Before we start scripting, let's get
  71. 2:17comfortable. You can absolutely use the
  72. 2:19built-in script editor, but if you're an
  73. 2:21experienced developer, you probably have
  74. 2:23a preferred [music] text editor. Taking
  75. 2:25the time to set up script sync means
  76. 2:27that you can use your favorite editor
  77. 2:28and your favorite coding tools. Here
  78. 2:31I've synced everything to my local disk
  79. 2:32[music] and open the project in Cursor.
  80. 2:35Because it's on my local disk, I can use
  81. 2:36Git or any other version control system.
  82. 2:39Depending on how deep you are down the
  83. 2:41AI rabbit hole, and and listen, I'm not
  84. 2:43judging either way, you might also want
  85. 2:45to hook up the Studio MCP server to
  86. 2:47Claude.
  87. 2:48You might be tempted to start putting
  88. 2:49scripts directly onto objects in the
  89. 2:51workspace, but it inevitably leads to a
  90. 2:53maintenance nightmare as you start
  91. 2:55duplicating models. Instead, tag the
  92. 2:57parts you need to reason around and use
  93. 2:59the collection service to gather them up
  94. 3:01so you can work with them in a single
  95. 3:03place. Rather than running every frame,
  96. 3:05code in Roblox tends to be more
  97. 3:07event-driven, so you listen for changes
  98. 3:09>> [music]
  99. 3:10>> and then run some code.
  100. 3:11Speaking of events, communication
  101. 3:13between the client and the server occurs
  102. 3:16using what are called remote events. We
  103. 3:17have a video on this subject, too. Link
  104. 3:19in the description.
  105. 3:21Here, the client performs all sorts of
  106. 3:23work to create a compelling visual for
  107. 3:24the player. It [music] takes a broken
  108. 3:26child model within the original model
  109. 3:28and adds it to a debris table.
  110. 3:30When a bullet hits the model, the script
  111. 3:32swaps it for the broken one, [music]
  112. 3:34unanchors the parts so that physics
  113. 3:35apply, and then makes them go flying.
  114. 3:37Give those parts a randomized ejection
  115. 3:39vector.
  116. 3:41A simple particle effect then amps up
  117. 3:43the sense of destruction.
  118. 3:44Finally, though, the client script
  119. 3:46notifies the server, "Hey, player one
  120. 3:48broke this object." using a remote
  121. 3:50event. In response, the server
  122. 3:52replicates the action to all other
  123. 3:53clients, spawns loot only for player
  124. 3:56one, and then destroys the object. The
  125. 3:58final situation is very instructive. On
  126. 4:01player one, we see debris and a few
  127. 4:03gems. On player two, just the debris,
  128. 4:05but critically, it's [music] different
  129. 4:06debris due to the random nature of the
  130. 4:08client code. On the server, we don't see
  131. 4:10anything at all because the server is
  132. 4:12keeping track of state, not visuals.
  133. 4:15There's also general housekeeping, most
  134. 4:17of which uses the player and character
  135. 4:19events. When a player joins for the
  136. 4:21first time, initialize their data. If
  137. 4:23they're returning, load their data from
  138. 4:25a data store. Manipulate that data over
  139. 4:27the course of their session and save it
  140. 4:28when they leave. Do you plan to
  141. 4:30implement your own character solution or
  142. 4:32use default avatars?
  143. 4:34Will players use the built-in spawn
  144. 4:36system, [music] or do you need to create
  145. 4:37your own? It's not the most exciting
  146. 4:40scripting work in the world, but it
  147. 4:41creates the
  148. 4:42testable skeleton of of your experience.
  149. 4:45Or whatever metaphor you prefer.
  150. 4:47There are a couple other key features to
  151. 4:49mention, but they're situational. First,
  152. 4:51[music] streaming. If players can see
  153. 4:53beyond 100 m or so, that's 357 studs in
  154. 4:57Roblox parlance, you probably want to
  155. 4:59enable streaming. I mention streaming
  156. 5:01all the time on this channel and
  157. 5:02probably need to have my title changed
  158. 5:04>> [music]
  159. 5:04>> to chief streaming evangelist, but a big
  160. 5:06gotcha with streaming is to organize
  161. 5:08your instances into models and mark them
  162. 5:10as atomic. Marking models as atomic
  163. 5:13means that clients get the whole model
  164. 5:14or none of it, which makes it
  165. 5:16dramatically easier to reason around the
  166. 5:18modeling code. Imagine a house streaming
  167. 5:20in incrementally so you get the walls
  168. 5:22and the floor, and then a few
  169. 5:24milliseconds later the roof and the
  170. 5:25doors, and then the windows follow a
  171. 5:27quarter second after that. It'd be a
  172. 5:29nightmare to code around. You want your
  173. 5:31scripts to be only minimally aware of
  174. 5:33the part composition of a model rather
  175. 5:35than having to constantly check to make
  176. 5:37sure they have everything they need.
  177. 5:39The other key feature is server
  178. 5:41authority. If you're designing a
  179. 5:42competitive multiplayer experience,
  180. 5:44check out server authority. It prevents
  181. 5:46entire classes of cheats like fly hacks
  182. 5:49and speed hacks [music]
  183. 5:50by not trusting clients to report their
  184. 5:52position or state. It moves ownership of
  185. 5:55the player from the client, where they
  186. 5:56can cheat, to the server, where they
  187. 5:58can't.
  188. 5:59It's too much to cover here and still in
  189. 6:01beta, but I'll link to the documentation
  190. 6:03in the description, which has three
  191. 6:05sample games to help you understand the
  192. 6:06difference in project structure when
  193. 6:08server authority is enabled.
  194. 6:11To close things out, let's review two
  195. 6:12more features from this experience.
  196. 6:14[music]
  197. 6:14Procedural generation and
  198. 6:17gates.
  199. 6:18As you can see here, our view in
  200. 6:20building in Studio is quite different
  201. 6:22from the in-game view.
  202. 6:24You don't have to do this, of course,
  203. 6:25but if you want a procedural world, you
  204. 6:27can create any number of discrete
  205. 6:28building blocks, and then have the
  206. 6:30server put them together at runtime.
  207. 6:32Rather than [music] each client having
  208. 6:34to do that work locally, they all just
  209. 6:35get the version the server created.
  210. 6:37Here, we have a server script that
  211. 6:39initializes the experience. It passes a
  212. 6:41desired room count and a random seed to
  213. 6:44the map gen module. Everything is
  214. 6:46hardcoded here for demo purposes, but
  215. 6:48could just as easily be random. [music]
  216. 6:50The module script starts by taking every
  217. 6:52room and hallway in the prefabs folder
  218. 6:54and sticking them into tables so they're
  219. 6:56easy to work with.
  220. 6:57After some cleanup, you can see that it
  221. 6:59adds hallways and rooms until it reaches
  222. 7:01the desired number. If it runs out of
  223. 7:03unique rooms, it starts duplicating.
  224. 7:05Add hallway and room mostly deals with
  225. 7:07orientation and clearing rooms that have
  226. 7:10already been used from the table to make
  227. 7:12sure you don't get the same room over
  228. 7:13and over due to bad luck with
  229. 7:14randomization. And voila, a layout. And
  230. 7:17another, and another.
  231. 7:19Gates sure seem like they should be
  232. 7:21easy, but the implementation here shows
  233. 7:23off the separation of server and client
  234. 7:25concerns really well. You can see that
  235. 7:27we have a grill positioned below the
  236. 7:29map, and when we enter a room, the
  237. 7:30server sets the closed attribute on that
  238. 7:32grill to true or false. Then the client
  239. 7:35takes over.
  240. 7:36In what you might describe as a
  241. 7:38suboptimal approach, the client checks
  242. 7:40every grill once per frame to see if
  243. 7:42it's current open or closed state
  244. 7:44differs from the closed attribute that
  245. 7:45the server set. If the state differs,
  246. 7:48get the open and closed positions from
  247. 7:50the grill spot open and grill spot
  248. 7:52closed attachments, and play that tween.
  249. 7:55Is there a way to make this process
  250. 7:56event-driven rather than checking every
  251. 7:58frame? Probably yes, but but that's game
  252. 8:01development. Even if we look at it and
  253. 8:03think we can do better, optimizing
  254. 8:04[music]
  255. 8:05this module might not yield any tangible
  256. 8:07performance gains. We're only going to
  257. 8:09have a few gates at a time, so it's
  258. 8:10probably [music] better to just keep the
  259. 8:12simpler code. We can't let the perfect
  260. 8:14be the enemy of the good, or the good be
  261. 8:16the enemy of the
  262. 8:17You know what? I'm actually going to go
  263. 8:19back and see if I can rewrite that
  264. 8:20module.
  265. 8:22For so much more on how to work within
  266. 8:23Roblox's client-server architecture,
  267. 8:25check out the documentation at
  268. 8:27create.roblox.com.
  269. 8:29I want to extend a huge thank you to Mr.
  270. 8:31Chicken Rocket and Dev Odysseus for all
  271. 8:34their help and support on this video,
  272. 8:36and an equally large thanks to all of
  273. 8:37you for watching.
  274. 8:38See you next time.

About this transcript

This page contains the full transcript of How client-server architecture works on Roblox by Roblox Creators, generated from the public captions YouTube serves with the video. The transcript has 1,716 words across 274 segments, with the original timestamps preserved so you can click any line to jump to that moment in the embedded player.

What you can do with it

Use the transcript to take notes, quote the speaker, build a study guide, generate a summary with ChatGPT or Claude via the YouTube Summary tool, or export it as a timed subtitle file with YouTube to SRT. You can also re-open it in the transcriber to choose a caption track available on the video.

Free YouTube transcript tool

YouTube2Text is a free YouTube transcript generator — no signup, no daily limit. Paste any YouTube link and get the full transcript instantly, with timestamps, click-to-jump, caption language selection, AI prompts for ChatGPT, Claude, and Gemini, and exports to TXT, SRT, VTT, or Markdown.