YouTube2Text

Camera Manipulation (Spectate & Cutscenes) - Roblox Advanced Scripting #32 (2025) — Transcript

by BrawlDev · 6,058 words · 806 segments · language en · Watch on YouTube

Full transcript

  1. 0:00H thanks for stopping by everyone I just
  2. 0:03hate these round base games that make
  3. 0:04you have to wait until the next game
  4. 0:06starts when you join into the game but
  5. 0:08at least this game has a spectate mode
  6. 0:10so I'm just going to click on this and
  7. 0:12see what's happening wait Newbert who is
  8. 0:16this random shadowman standing right
  9. 0:18behind you he looks a little creepy like
  10. 0:20are you not phased by this at all
  11. 0:21Newbert uh who am I kidding Newbert just
  12. 0:24has his airpods in he can't even hear or
  13. 0:26see what's happening Newbert I think you
  14. 0:28should turn around I don't want you
  15. 0:29getting killed wait new bird he's coming
  16. 0:32for you new bird he's got his airpods
  17. 0:34and he can't hear hear me no
  18. 0:37newd
  19. 0:40no ah whatever at least I get to play
  20. 0:42the next game now that's all that
  21. 0:44matters all right let's think about this
  22. 0:46for a minute this video is going to be
  23. 0:48about camera manipulation which is based
  24. 0:50off of the idea of our camera object now
  25. 0:53our camera is what allows us to view the
  26. 0:563D World in its simplest definition and
  27. 0:59there are ways that we can manipulate
  28. 1:01this camera uh through changing some
  29. 1:03properties and through scripting as well
  30. 1:05which is what I'm going to be teaching
  31. 1:06you how to do inside of this episode so
  32. 1:09from this example that you saw here when
  33. 1:11I pressed the spectate button it moved
  34. 1:14the camera to this specific position
  35. 1:16right here to be in front of Newbert and
  36. 1:19another example that I've created is we
  37. 1:20can hold left shift to Sprint and that
  38. 1:23is going to zoom our camera outward just
  39. 1:25a little bit and then if I let go then
  40. 1:27it's going to zoom the camera back in so
  41. 1:29so this is manipulating the way that we
  42. 1:32move our camera through scripting if
  43. 1:34let's say we had a system like this in
  44. 1:36place and so these are just some
  45. 1:38examples of being able to manipulate the
  46. 1:40camera and that's what we're going to be
  47. 1:41doing inside of this video so with that
  48. 1:43being said let's go ahead and go
  49. 1:45straight into the episode now that we
  50. 1:46understand it let's Implement camera
  51. 1:48manipulation inside Roblox Studio but I
  52. 1:50do want to emphasize that when we're
  53. 1:53changing the camera either through its
  54. 1:54properties or through scripting we want
  55. 1:56to do it on the local side because every
  56. 1:59single player has their own camera since
  57. 2:01what they see in the world is going to
  58. 2:03be unique from each other so we're going
  59. 2:04to get into more about that later when
  60. 2:06we start scripting it but as of right
  61. 2:08now what I want to do is introduce to
  62. 2:10you some properties that we can change
  63. 2:12with the camera and the first place to
  64. 2:13look is inside of starter player so I'm
  65. 2:16going to select this and there should be
  66. 2:17a category called camera right over here
  67. 2:20that has these properties that we can
  68. 2:21change for a starting player when they
  69. 2:23join into the game so I'm just going to
  70. 2:25scale this out so we can show the
  71. 2:27properties um two of these involve the
  72. 2:30zoom distance for the camera so
  73. 2:31basically how far away can the player
  74. 2:33zoom and how close in can they Zoom so
  75. 2:36by default the max Zoom distance is 128
  76. 2:39so if I were to demonstrate this to you
  77. 2:41I can just reduce this to let's say 20
  78. 2:43and I can increase the minimum Zoom
  79. 2:45distance to let's say 10 so now if I hit
  80. 2:47play then what should happen is that if
  81. 2:50I try to zoom out it's not going to work
  82. 2:52because I set the max Zoom distance to
  83. 2:5420 studs now if I try zooming in it's
  84. 2:57only going to go in as close as 10 studs
  85. 3:00from the player so it kind of gives a
  86. 3:03constraint to how far the distances are
  87. 3:06um with the camera and so that's uh one
  88. 3:08set of properties so I'm just going to
  89. 3:10hit backspace and just so I'm just going
  90. 3:11to hit backspace really quick um next
  91. 3:13thing is camera mode so there's only two
  92. 3:15options it's either classic or lock
  93. 3:17first person I think that one's pretty
  94. 3:18self-explanatory now Dev camera
  95. 3:21occlusion mode is essentially a way for
  96. 3:24the camera to handle objects that are
  97. 3:26obstructing the character with the
  98. 3:29camera's view so if I were to create a
  99. 3:31part just like this I'm just going to
  100. 3:32create like some tall structure right
  101. 3:34here and what I'm essentially going to
  102. 3:37do is hit play so what's going to happen
  103. 3:40is when the camera tries to deal with
  104. 3:43objects that are obstructing the player
  105. 3:45like this then it's going to zoom the
  106. 3:47camera into where the player is just
  107. 3:49like this I think you kind of notice
  108. 3:51what's happening here so this is what's
  109. 3:53happening by default but there's
  110. 3:55actually a second option we can change
  111. 3:57for the occlusion mode and that's called
  112. 3:59called invisicam so when I hit play now
  113. 4:02uh once we go into the game then instead
  114. 4:04of zooming into the character what it's
  115. 4:06going to do is it's going to set the
  116. 4:08transparency of the objects that's
  117. 4:11blocking the player to semi-transparent
  118. 4:13or like 0.5 or whatever you want to
  119. 4:15describe this as so that's what
  120. 4:17invisicam does and so I think this is
  121. 4:18something you should experiment with uh
  122. 4:20depending on the kind of game that
  123. 4:21you're creating now there's two more
  124. 4:23options here which is basically what
  125. 4:25allows the developer to set uh a fixed
  126. 4:29camera movement type for the user if
  127. 4:31they joins the game I'm going to explain
  128. 4:33these camera types in a little bit um
  129. 4:35but that's essentially some of the
  130. 4:36properties that we can set for um a
  131. 4:39starting player okay but now I want to
  132. 4:41get into the camera object itself and
  133. 4:44this is located inside of workspace so
  134. 4:47if I open this up then our camera should
  135. 4:49be right over here and there's two
  136. 4:51properties that I want to look at that
  137. 4:52are going to be important one of them
  138. 4:54being camera subject and the other one
  139. 4:56being camera type which is both under
  140. 4:59the camera category so to explain what
  141. 5:01camera type is I'm just going to hit
  142. 5:03test and hit play and it's basically a
  143. 5:07property that allows us to change what
  144. 5:10kind of camera that we have going for
  145. 5:12this specific player or ideally for all
  146. 5:14players that are inside of the game so
  147. 5:16by default it's set to custom which is
  148. 5:19essentially uh whatever we pick for the
  149. 5:22camera mode that's inside of our
  150. 5:23settings which by default is classic so
  151. 5:27classic is what allows us to move around
  152. 5:28freely the this is what the classic
  153. 5:30camera type is but then we can change
  154. 5:32this to something else like let's say
  155. 5:33attach so the way this camera goes is
  156. 5:37different than what we had before and if
  157. 5:39I were to do fixed then it's just going
  158. 5:41to stay in place and then if we select
  159. 5:44something else like orbital then it's
  160. 5:46going to have this weird like top down
  161. 5:48perspective so you can see all of these
  162. 5:50different types of cameras that we can
  163. 5:53have for our game and depending on the
  164. 5:55kind of game that you're creating I
  165. 5:56think picking one of these camera types
  166. 5:58is going to be pretty beneficial I um so
  167. 6:00that's something I wanted to show so I'm
  168. 6:02just going to quickly set this back to
  169. 6:04custom and the other property is called
  170. 6:05the camera subject now by default our
  171. 6:08camera subject is the humanoid of our
  172. 6:12local player so basically the subject is
  173. 6:15essentially the reference part or
  174. 6:18instance that the camera is attached to
  175. 6:21so we can actually change this to be a
  176. 6:23reference to a different part by simply
  177. 6:25going to our camera uh clicking on
  178. 6:27camera subject and then we can select
  179. 6:29whatever reference we want for our
  180. 6:32camera subject so let's say we want it
  181. 6:34to be the part that we created so the
  182. 6:36camera has now moved to be a part to be
  183. 6:39the camera for this uh part that we
  184. 6:42created because this is now our
  185. 6:44reference point rather than our
  186. 6:46character so that's a little something I
  187. 6:47wanted to show as well and if we want to
  188. 6:49revert this back I'm just simply going
  189. 6:50to say camera subject and then I'm going
  190. 6:52to click back on our humanoid so that we
  191. 6:55now have our reference being our
  192. 6:57character so with what we know right now
  193. 6:59we can start scripting our camera and
  194. 7:01what we're going to do is create a local
  195. 7:03script in let's say starter player and
  196. 7:06starter player scripts we're going to
  197. 7:08hit the plus sign and we're going to
  198. 7:09insert a local script and we're going to
  199. 7:11delete this code right here so the first
  200. 7:13thing we have to do is make reference to
  201. 7:15our camera by saying local camera equals
  202. 7:18game.or space. camera now you might
  203. 7:21think that this is the camera that we're
  204. 7:22trying to reference here but that's
  205. 7:24actually not correct even though there
  206. 7:26is a camera inside of workspace this is
  207. 7:29not the the right kind of camera that we
  208. 7:30want to manipulate because there's a
  209. 7:32difference between a camera and a
  210. 7:35current camera camera is basically the
  211. 7:38Studio's camera but what we want to
  212. 7:40manipulate is the current camera which
  213. 7:42is basically our local players camera so
  214. 7:45instead of camera we're going to say
  215. 7:47current camera just like this and so
  216. 7:50when we're manipulating the camera
  217. 7:51inside of a local script we want to use
  218. 7:53current camera okay so now that we have
  219. 7:55that what we can do is manipulate a
  220. 7:57property that camera might have like
  221. 7:59let's say the C frame of it and when we
  222. 8:01change the C frame of the camera it's
  223. 8:02literally going to move the camera in a
  224. 8:04specific point inside of the game so
  225. 8:08what we can do is say camera. cframe
  226. 8:11equals and we can just create a new
  227. 8:12cframe we can say cframe do new open
  228. 8:15close parenthesis we could just say 100
  229. 8:17100 and 100 so you might think that this
  230. 8:21would work but let me show you what
  231. 8:23happens if we hit play so I'm going to
  232. 8:24go to test and hit play and what we
  233. 8:27should see is the game is still running
  234. 8:30basically as expected without executing
  235. 8:32the script it seems like but the problem
  236. 8:34that lies here is this code actually did
  237. 8:38run but the thing is roblox's default
  238. 8:41camera system overrode this command that
  239. 8:43we created here and so what we need to
  240. 8:45do is not have roblox's um default
  241. 8:49camera system override our scripts when
  242. 8:51we make modifications to the camera and
  243. 8:54so what we need to do is set the camera
  244. 8:56type to scriptable so if you're
  245. 8:59remembered um for the camera there was a
  246. 9:01property here for camera type and
  247. 9:03scriptable was actually one of them so
  248. 9:05this is what we need to set the camera
  249. 9:06type to before we make any scripting
  250. 9:08changes to the camera so what we're
  251. 9:10going to do is hit stop I'm going to go
  252. 9:12to the local script and before we make
  253. 9:13the cframe change what we're going to do
  254. 9:15is say camera. camera type equals in
  255. 9:19quotations we're going to say scriptable
  256. 9:22just like this and I'm also going to add
  257. 9:25a task. weight for about 1 second so
  258. 9:27that the game loads in in time before we
  259. 9:29make this change so now if we go into
  260. 9:30the game and hit play then what we
  261. 9:32should see is that our camera's C frame
  262. 9:36is now located at uh the coordinates 100
  263. 9:40100 and 100 with X Y and Z respectively
  264. 9:42but we haven't changed like the angle of
  265. 9:45it or like where we're looking at in
  266. 9:47specific but this is essentially how we
  267. 9:49change the position of the camera inside
  268. 9:52of the game once we change the camera
  269. 9:54type to be scriptable so let's say we
  270. 9:56wanted to have a cutscene system where
  271. 9:58we have one starting point and one
  272. 10:00ending point for the camera to
  273. 10:03essentially go from the starting point
  274. 10:04to the ending point we can do that by
  275. 10:06manipulating the CF frame of the camera
  276. 10:08using our scriptable camera type and so
  277. 10:11what we can do is essentially create two
  278. 10:13points that go from point A to point B
  279. 10:16by simply just going to model I'm just
  280. 10:17going to insert a part over here I'm
  281. 10:20going to call this start and then I'm
  282. 10:23going to duplicate this and then move
  283. 10:25this somewhere that's semi far away I'm
  284. 10:28also going to change the the rotation of
  285. 10:29this just a little bit and I'm going to
  286. 10:31rename this one to end and so what we
  287. 10:34can do is have our camera's CF frame
  288. 10:38start here and then we can have the
  289. 10:40camera move into the direction of where
  290. 10:43the end part is over here and so that
  291. 10:45way we can create this sort of cinematic
  292. 10:47experience by going from the first part
  293. 10:49to the next part so what we're going to
  294. 10:50do inside of the local script is
  295. 10:52reference these two parts by dropping
  296. 10:54two lines and we're going to say local
  297. 10:56start equals game. workpace colon wait
  298. 10:59for Child open close parenthesis start
  299. 11:03and then we're going to do the same
  300. 11:04thing for the End by saying local end
  301. 11:06equals game. workspace colon wait for
  302. 11:10Child open and close parentheses end now
  303. 11:13I realized that Roblox is triggering a
  304. 11:15keyword here so I think we should say
  305. 11:17end part and start part instead of just
  306. 11:20start and end just like that so now what
  307. 11:22we're going to do is change the cframe
  308. 11:25of this camera to be the cframe of the
  309. 11:27start part so we're going to say start
  310. 11:30part. cframe and then what we can do is
  311. 11:33put a task. we for about 2 seconds and
  312. 11:35then we can say camera. cframe equals
  313. 11:39end part. cframe so if we go into the
  314. 11:42game hit test and hit play then it's
  315. 11:45going to start at this part like the
  316. 11:48start part C frame and then it's going
  317. 11:49to go to the end parts C frame just like
  318. 11:51that but it didn't do it in a smooth
  319. 11:53fashion like we literally hardcoded the
  320. 11:55C frame to change uh after about like 2
  321. 11:58seconds but what we can do is add a
  322. 12:01smooth transition with tween service so
  323. 12:04what we can do is drop two lines above
  324. 12:06here and say local tween service equals
  325. 12:10game colon get service tween service and
  326. 12:12then what we can do is instead of
  327. 12:15directly changing the C frame just like
  328. 12:16this I'm just going to comment this out
  329. 12:18I'm going to create a tween and then
  330. 12:20play it by saying tween service colon
  331. 12:24create open and close parenthesis and
  332. 12:26then we're going to set camera as our
  333. 12:29object and then we're going to add a
  334. 12:31tween info object so we're just going to
  335. 12:33create one here by saying tween info.
  336. 12:36new open close parenthesis we're going
  337. 12:38to make this last for 2 seconds and then
  338. 12:41uh we're going to have a table full of
  339. 12:43the goals that we're trying to
  340. 12:45accomplish with this tween which in this
  341. 12:47case is going to be the C frame so we're
  342. 12:49going to set this equal to endp part. C
  343. 12:53frame just like that and then we're
  344. 12:54going to play this tween by saying colon
  345. 12:57play open and close parentheses by the
  346. 12:59of it uh we can even get rid of these
  347. 13:01two lines as well we don't really need
  348. 13:02them and now if we go into the game and
  349. 13:05hit play then what we should see is that
  350. 13:08it did like a little smooth transition
  351. 13:10with tween service by having the
  352. 13:11starting point go to the ending point
  353. 13:14just like that I can even show it to you
  354. 13:16again by waiting for two seconds before
  355. 13:18the script fires so 2 seconds have
  356. 13:21passed and it went from the starting
  357. 13:22point to its ending point and so that is
  358. 13:25essentially how we create this sort of
  359. 13:27transition with camera manipul ation and
  360. 13:29tween service now there's two rendering
  361. 13:31properties I want to show you that you
  362. 13:33might find useful but before we do I'm
  363. 13:35going to disable our local script and
  364. 13:37I'm going to select the camera so
  365. 13:39there's two properties I want to show
  366. 13:40the first one is focus and the second
  367. 13:42one is field of view field of view is a
  368. 13:45property that essentially tells us the
  369. 13:48extent to which we can see the world
  370. 13:50through our screen and basically what I
  371. 13:52mean is if we change this field of view
  372. 13:54from 70 to let's say 100 by increasing
  373. 13:57it then it's going to compress the
  374. 13:59screen vertically so that it feels like
  375. 14:02we can see more of the world than we can
  376. 14:04actually see um and if we do the
  377. 14:07opposite by changing this to something
  378. 14:09smaller like 40 then it's going to
  379. 14:11expand the screen vertically outward so
  380. 14:14that it feels like we're zoomed in and
  381. 14:16we can actually see something that's
  382. 14:17closer so a smaller fov would be useful
  383. 14:20if let's say we wanted to zoom in on
  384. 14:22something and then uh a bigger fov would
  385. 14:25be cool for something like if the user
  386. 14:27has like a shift to Sprint system and we
  387. 14:29want the player to see that they are
  388. 14:32moving Faster by changing the fov to
  389. 14:34something where we can see more of the
  390. 14:36world so that's basically what fov is
  391. 14:39I'm going to set this back to 70 and the
  392. 14:42other property is called Focus which is
  393. 14:44essentially a point in the world where
  394. 14:47we want roblox's graphical system to
  395. 14:50prioritize anything it needs to render
  396. 14:52within this specific Focus Point versus
  397. 14:55anything that's farther away from this
  398. 14:57Focus point now by default you don't
  399. 15:00really have to worry about this property
  400. 15:01because as you can see while I'm moving
  401. 15:03my camera the focus is being updated
  402. 15:06with the cframe of the camera and
  403. 15:08usually the focus property is synonymous
  404. 15:11with the cframe camera because when we
  405. 15:13have the camera subject be set to let's
  406. 15:15say the the player's humanoid then the
  407. 15:18focus point is going to be on the
  408. 15:20character's humanoid um but if we let's
  409. 15:23say had a customized system where we
  410. 15:26have a scriptable camera type we would
  411. 15:28have to change this Focus property
  412. 15:30manually and because this is being
  413. 15:32updated every single frame we would have
  414. 15:34to use run service to update the focus
  415. 15:37every single frame when we're using our
  416. 15:41uh own scriptable camera type and that's
  417. 15:43something I wanted to introduce to you
  418. 15:45that you might want to consider using
  419. 15:47inside of the future okay so now I'm
  420. 15:48going to show you what are called
  421. 15:50raycast Methods and how they apply with
  422. 15:52the camera now I haven't made a
  423. 15:54dedicated tutorial on rayc casting yet
  424. 15:56so whatever I talk about in this episode
  425. 15:58I'm going to be emitting the technical
  426. 16:00details of the ray casting part but I
  427. 16:02still want to show some methods that are
  428. 16:04very useful with the camera that I think
  429. 16:05you'd want to use for your game and one
  430. 16:07of those methods is called get parts
  431. 16:10obscuring Target now basically what this
  432. 16:12method does is we take a specific point
  433. 16:15inside of the game and we want to detect
  434. 16:17if there's any instances that are
  435. 16:19blocking that uh position inside of the
  436. 16:22game so let's say we take this spawn
  437. 16:24location right here and we want to get
  438. 16:25the position of this so with the
  439. 16:27position of the spawn location we want
  440. 16:29to check if there's any parts that are
  441. 16:30blocking it from the camera but as of
  442. 16:32right now we can see the spawn location
  443. 16:35but if we were to hide behind this wall
  444. 16:37right here then this is going to be a
  445. 16:39part that is obscuring this spawn
  446. 16:42location's position so we can do that
  447. 16:45through our script using this camera
  448. 16:47method and so that's what I'm going to
  449. 16:48be showing you how to add right now so
  450. 16:50what we're going to do is go to our
  451. 16:51local script I'm going to drop two lines
  452. 16:54well actually first thing we're going to
  453. 16:55do is we're going to comment out
  454. 16:56everything we've had up until this point
  455. 16:59and I'm also going to comment out this
  456. 17:01task. weight statement at the beginning
  457. 17:02but we're going to keep the camera
  458. 17:03reference so here's what we're going to
  459. 17:05do um we're going to say local Parts
  460. 17:10obscuring Target equals camera colon get
  461. 17:15parts obscuring Target open close
  462. 17:18parenthesis and inside of here it takes
  463. 17:20two parameters one of them is cast
  464. 17:22points and the other one is an ignore
  465. 17:24list so I'm going to explain what both
  466. 17:25of these are so cast points is basically
  467. 17:28a table full of these Vector 3 positions
  468. 17:31that I was mentioning earlier before
  469. 17:32with the spawn location now you can have
  470. 17:34more than one position if you want but
  471. 17:36I'm going to say for the sake of this
  472. 17:37example this spawn location position
  473. 17:39right here so what we're going to do is
  474. 17:41drop a line at the beginning and we're
  475. 17:43going to say local cast points equals
  476. 17:47game. workpace colon wait for child
  477. 17:51spawn location and then we're going to
  478. 17:53wrap this with uh curly brackets to make
  479. 17:56this a table so this is our cast points
  480. 17:58and we can pass this in as the first
  481. 18:00parameter so we're going to say cast
  482. 18:01points just like this and now the second
  483. 18:02thing is an ignore list an ignore list
  484. 18:05is basically a table full of instances
  485. 18:08that we don't want to include uh for
  486. 18:10when we're detecting if there's a part
  487. 18:13that's obscuring the cast Point position
  488. 18:15that we're interested in so let's say
  489. 18:17for this part right here if we add this
  490. 18:19to the ignore list then we can still see
  491. 18:22this part's location because we added
  492. 18:24this to the ignore list so we can do
  493. 18:26that in our local script by saying local
  494. 18:28a nor list equals open and close curly
  495. 18:31braces and then we can add that inside
  496. 18:34of our second argument just like this
  497. 18:36now there is going to be a problem with
  498. 18:38this ignore list so now what I'm going
  499. 18:40to do is I want to be able to
  500. 18:42demonstrate this inside of Roblox studio
  501. 18:43and the best way we can do this is by
  502. 18:45using run service so that we can get a
  503. 18:47frame by frame uh representation inside
  504. 18:49of the output so here's what we're going
  505. 18:51to do we're going to say local run
  506. 18:55service equals game get service run
  507. 18:58serice
  508. 18:59run service just like this and what I'm
  509. 19:01going to do is say run
  510. 19:05service do hardbeat colon connect
  511. 19:08function open close parentheses enter
  512. 19:10and I'm going to take this line and
  513. 19:12paste it inside of here now what I'm
  514. 19:14going to do is check if the number of
  515. 19:16instances that we get that are obscuring
  516. 19:18the target is greater than zero so that
  517. 19:20tells us if there is at least one part
  518. 19:22that's blocking our Target so we're
  519. 19:24going to say if uh pound symbol parts of
  520. 19:27scaring Target is greater than Z then
  521. 19:29we're going to print
  522. 19:32something is blocking the Target and
  523. 19:36then what I'm going to do is print out
  524. 19:38all the parts that are blocking the
  525. 19:39target so we're going to say for I comma
  526. 19:42part in I pairs open and close
  527. 19:45parenthesis Parts obscuring Target do
  528. 19:48and then we're going to print the part
  529. 19:50itself and then to separate every single
  530. 19:53time we check this we're we're just
  531. 19:54going to separate this using uh a couple
  532. 19:56dashes Okay so here's what we have so
  533. 19:59far let's go into the game and hit play
  534. 20:01now there is going to be a problem with
  535. 20:03this so right
  536. 20:07now oh hold on the script is not working
  537. 20:10oh my bad there was a typo on my end um
  538. 20:12so we're supposed to say spawn location.
  539. 20:14position because this is a table full of
  540. 20:17vector 3 values we're not putting in the
  541. 20:20instance themselves so now if we go into
  542. 20:22the game and hit play there should be a
  543. 20:24problem here and I'm going to show you
  544. 20:26why so it says in the output that there
  545. 20:27is something that's blocking the target
  546. 20:29which is the spawn location itself
  547. 20:31that's because for the cast points we're
  548. 20:33interested in the position of the spawn
  549. 20:35location not the spawn location itself
  550. 20:38so what we need to do is add the spawn
  551. 20:40location to the ignore list so that it's
  552. 20:43not counted when we are looking for
  553. 20:45parts that are scaring it so I'm just
  554. 20:47going to copy this line here and I'm
  555. 20:48going to paste it inside of the ignore
  556. 20:50list and now what we're going to do is
  557. 20:52hit play so the spawn location should
  558. 20:54not be included with any part that's
  559. 20:56obscuring it um so now if we look at
  560. 21:00what's happening here uh what I'm going
  561. 21:01to do is block the spawn location using
  562. 21:05this part and so now it's going to say
  563. 21:06that something is blocking the target
  564. 21:08which is um this part right here uh I
  565. 21:10can even stand in front of it and
  566. 21:12there's going to be a bunch of hats and
  567. 21:14accessories from my avatar that's
  568. 21:16blocking this spawn location as well and
  569. 21:18it's being displayed in the output here
  570. 21:20every single frame and so this is
  571. 21:21essentially what this function does and
  572. 21:23you can definitely find usefulness with
  573. 21:25this function so this is something I
  574. 21:26wanted to introduce to you that you
  575. 21:28might that you might want to use for
  576. 21:29your games okay the next method I want
  577. 21:30to show you is called world two screen
  578. 21:33point now the idea behind this method is
  579. 21:35that we want to take a vector 3 position
  580. 21:39of whatever part that's inside of the
  581. 21:40game and we want to convert that to a 2d
  582. 21:44position or a vector 2 value that's
  583. 21:46going to be displayed on our screen uh
  584. 21:49that's relative to the camera as well so
  585. 21:51let's say we had this part that's right
  586. 21:52over here and we wanted to take that
  587. 21:54Vector 3 position of this part and
  588. 21:57convert it to a screen position that's
  589. 21:59going to be displayed on our screen so
  590. 22:02that's essentially what this function is
  591. 22:03going to do now instead of coding this
  592. 22:05up I'm going to show you a really
  593. 22:07practical example of this so that you
  594. 22:09get an idea of what I'm talking about
  595. 22:11okay so this video demonstrates what I'm
  596. 22:12talking about and essentially What's
  597. 22:14Happening Here is that there's all these
  598. 22:16coins that are scattered across the map
  599. 22:17and when the player picks up the coin
  600. 22:20then it's going to convert the vector 3
  601. 22:23position of that coin and give us a 2d
  602. 22:26position of that part that's on our
  603. 22:29screen that's relative to the camera and
  604. 22:31then it's going to create this uh image
  605. 22:33label of a coin and display it at that
  606. 22:35position and then it's just going to fly
  607. 22:37off to the screen once it's done but
  608. 22:39this is essentially what I'm talking
  609. 22:40about when it comes to converting a 3D
  610. 22:43point and converting it to a 2d point on
  611. 22:46the screen and this is a really
  612. 22:47practical example of using this function
  613. 22:49which I want to give credit to my admin
  614. 22:51for creating this and also for creating
  615. 22:52the script as well so essentially it
  616. 22:54returns so essentially World 2 screen
  617. 22:57Point takes one parameter which is uh
  618. 22:59the position of the coin that was being
  619. 23:01picked up and then it returns a vector
  620. 23:04that gives us the X and Y components of
  621. 23:06the 2D screen and this is a Boolean that
  622. 23:09tells us whether this actually fits on
  623. 23:11the screen or not and then it creates
  624. 23:13the coin image label and shows it on
  625. 23:14screen so then as you can see we take a
  626. 23:16udm 2 value and we use the vectors X and
  627. 23:19Y component to change the position uh of
  628. 23:22the the image label for the 2D screen so
  629. 23:25this is a little practical example I
  630. 23:26wanted to show and I hope that this gave
  631. 23:27you insight into using this function now
  632. 23:30there is another method called World 2
  633. 23:32viewport frame but this is literally the
  634. 23:34same exact method as World 2 screenpoint
  635. 23:38but there's only one difference and that
  636. 23:41is we're not taking into account the guy
  637. 23:43inset that is built into every single
  638. 23:45Roblox game unless the developer
  639. 23:47specifies not having this GUI inset and
  640. 23:50what I mean by this GUI inset is that
  641. 23:52Roblox reserves a specific uh amount of
  642. 23:56space on the top of the screen for their
  643. 23:58own own customized UI like these buttons
  644. 24:00over here and so with this function over
  645. 24:02here we're essentially ignoring this top
  646. 24:04part here when we're using World 2
  647. 24:06viewport frame so that's the only
  648. 24:08difference and I think it's a pretty
  649. 24:09nice distinction uh from the two
  650. 24:11functions so depending on which one you
  651. 24:13use I hope you find practical use with
  652. 24:15these functions and I hope you found
  653. 24:17this part to be informative so for
  654. 24:19today's challenge I want you to create
  655. 24:20this spectate mode GUI system where we
  656. 24:24have a button here that says spectate
  657. 24:25and if we click on it then it's going to
  658. 24:27show this little panel here that
  659. 24:30displays what player we're currently
  660. 24:32spectating and we can click these arrows
  661. 24:35to flip to different players perspective
  662. 24:38so that we can spectate them so if I
  663. 24:39press this right button then it's going
  664. 24:41to change the camera to reflect on this
  665. 24:44player's humanoid instead of my humanoid
  666. 24:47and then if I were to uh flip it back to
  667. 24:50my character then it's going to change
  668. 24:51my camera to reflect my character's
  669. 24:54humanoid and so we can do the same thing
  670. 24:56going reverse and we can do the same
  671. 24:57thing going forward so this is what I
  672. 24:59want you to create for this Challenge
  673. 25:01and for the sake of time so once you've
  674. 25:03given this a try then we can come back
  675. 25:04and dive deeper into this spectate mode
  676. 25:07GUI so for the sake of time I'm not
  677. 25:09going to be coding this with you step by
  678. 25:10step but I will show you what I did with
  679. 25:13my code so that hopefully it can give
  680. 25:14you a better understanding of how this
  681. 25:16system works so what we have here on the
  682. 25:19right side is a spectator screen GUI so
  683. 25:22if I open this then there's going to be
  684. 25:24a local script a frame and a button so
  685. 25:27the spectate button is the button down
  686. 25:29here and then spectate frame is the the
  687. 25:32little panel that shows the player's
  688. 25:33name that we're currently spectating and
  689. 25:36the left and right button so it can flip
  690. 25:38through different players so if I open
  691. 25:39this up there's a left button a right
  692. 25:41button and a text label that tells us
  693. 25:44the player's name that we're currently
  694. 25:45spectating so I'm just going to disable
  695. 25:47this and now we're going to analyze the
  696. 25:50local script behind it so basically what
  697. 25:52we have going on here is a player list
  698. 25:55that gives us a table of all the players
  699. 25:58that can spectate and then this position
  700. 26:00is the index value of the player that
  701. 26:03we're going to be viewing inside of the
  702. 26:05spectate mode GUI and there's two
  703. 26:08functions here so the first one is
  704. 26:09update player list this one just takes
  705. 26:11our player list and updates it with all
  706. 26:13the players that are currently available
  707. 26:14and then update camera is what allows us
  708. 26:17to change the camera subject of our
  709. 26:20current camera to whatever the player
  710. 26:23that we're currently spectating is to
  711. 26:26whatever player we're currently
  712. 26:27spectating and we get their humanoid
  713. 26:29with that and then we change the the
  714. 26:31text of the player name of that as well
  715. 26:33okay so once we press the spectate
  716. 26:35button so this button down here then
  717. 26:38it's going to update the player list
  718. 26:39automatically and it's going to give a
  719. 26:41check as to whether we are currently
  720. 26:43spectating and if we are then we're
  721. 26:44going to set that equal to true we're
  722. 26:46going to make the frame visible and
  723. 26:48we're also just as a safety measure
  724. 26:50we're going to make the character not be
  725. 26:52able to move while we're spectating and
  726. 26:54we're going to set the position
  727. 26:55automatically to one and then we're
  728. 26:58going to use update camera with the
  729. 27:01player that lies in the the position of
  730. 27:04one and if we're not spectating then
  731. 27:06we're just going to let the player move
  732. 27:07we're going to disable the frame and
  733. 27:09we're going to let the player have
  734. 27:11control again since we're not spectating
  735. 27:12anyone okay so that is what happens when
  736. 27:15we press spectate button so if we press
  737. 27:17the right button so if I were to load up
  738. 27:20the frame again it's this button right
  739. 27:22over here it's going to check whether we
  740. 27:24are spectating and if we're not then
  741. 27:25it's just going to return the function
  742. 27:27we're going to update the list again and
  743. 27:29then essentially What's Happening Here
  744. 27:31is that we're going to be updating the
  745. 27:33position before we update our players
  746. 27:36camera to that uh position inside of the
  747. 27:38player list so essentially What's
  748. 27:40Happening Here is that and if this
  749. 27:42increment is greater than the size of
  750. 27:45the player list then we're going to be
  751. 27:46going out of bound and we don't want to
  752. 27:48do that so what we do is we set the
  753. 27:51position back to one so we're
  754. 27:53essentially resetting it and if we're
  755. 27:55not going out of bound then we're just
  756. 27:56going to Simply take the position and
  757. 27:59add one to it so that we're flipping
  758. 28:00through the players of the player list
  759. 28:03and so that's what we do when we update
  760. 28:04the camera and we're essentially doing
  761. 28:06the same thing with the left button
  762. 28:08where we press it except this time
  763. 28:10instead of going forward we're going
  764. 28:13backwards so we're going to take the
  765. 28:15position and we're going to subtract it
  766. 28:16by one and we're going to see if this is
  767. 28:18less than one because if we have a value
  768. 28:21of zero well there's no such thing as an
  769. 28:23index value of zero so this is not going
  770. 28:25to work so if this is the case then
  771. 28:27we're going to set the position to the
  772. 28:30size of the player list so we're going
  773. 28:31to start backwards and if that's not the
  774. 28:33case then we're just simply going to
  775. 28:35decrement the position by subtracting it
  776. 28:37by one and then once again we're going
  777. 28:40to be updating the camera and that is
  778. 28:42essentially the rundown of this spectate
  779. 28:45GUI script and I hope that this
  780. 28:48explanation has helped you with
  781. 28:51understanding how this system is created
  782. 28:53so that's pretty much going to be it for
  783. 28:54this episode if you found this video to
  784. 28:56be very helpful then I encourage you to
  785. 28:58leave a like on this video And subscribe
  786. 29:00to the channel if you haven't already uh
  787. 29:02I would also like to give a shout out to
  788. 29:04all of my patreon members for supporting
  789. 29:06the work that I do and providing me with
  790. 29:08continuous support as well um I
  791. 29:09appreciate them a lot and if you want to
  792. 29:11have access to my scripts get early
  793. 29:12access to the videos then I encourage
  794. 29:14you to become a patreon member as well
  795. 29:16um your support would be very
  796. 29:18appreciative and if there and if you're
  797. 29:19still confused about some of the
  798. 29:20concepts that we talked about like C
  799. 29:22frames then I will have a link to that
  800. 29:24video for you right here to watch so go
  801. 29:26ahead and watch that if you haven't
  802. 29:27already also you can check out the other
  803. 29:29videos that are in my Advanced scripting
  804. 29:31tutorial guide and with that being said
  805. 29:33that's going to conclude this episode I
  806. 29:35will see you in the next one take care

About this transcript

This page contains the full transcript of Camera Manipulation (Spectate & Cutscenes) - Roblox Advanced Scripting #32 (2025) by BrawlDev, generated from the public captions YouTube serves with the video. The transcript has 6,058 words across 806 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.