Camera Manipulation (Spectate & Cutscenes) - Roblox Advanced Scripting #32 (2025) — Transcript
Full transcript
- 0:00H thanks for stopping by everyone I just
- 0:03hate these round base games that make
- 0:04you have to wait until the next game
- 0:06starts when you join into the game but
- 0:08at least this game has a spectate mode
- 0:10so I'm just going to click on this and
- 0:12see what's happening wait Newbert who is
- 0:16this random shadowman standing right
- 0:18behind you he looks a little creepy like
- 0:20are you not phased by this at all
- 0:21Newbert uh who am I kidding Newbert just
- 0:24has his airpods in he can't even hear or
- 0:26see what's happening Newbert I think you
- 0:28should turn around I don't want you
- 0:29getting killed wait new bird he's coming
- 0:32for you new bird he's got his airpods
- 0:34and he can't hear hear me no
- 0:37newd
- 0:40no ah whatever at least I get to play
- 0:42the next game now that's all that
- 0:44matters all right let's think about this
- 0:46for a minute this video is going to be
- 0:48about camera manipulation which is based
- 0:50off of the idea of our camera object now
- 0:53our camera is what allows us to view the
- 0:563D World in its simplest definition and
- 0:59there are ways that we can manipulate
- 1:01this camera uh through changing some
- 1:03properties and through scripting as well
- 1:05which is what I'm going to be teaching
- 1:06you how to do inside of this episode so
- 1:09from this example that you saw here when
- 1:11I pressed the spectate button it moved
- 1:14the camera to this specific position
- 1:16right here to be in front of Newbert and
- 1:19another example that I've created is we
- 1:20can hold left shift to Sprint and that
- 1:23is going to zoom our camera outward just
- 1:25a little bit and then if I let go then
- 1:27it's going to zoom the camera back in so
- 1:29so this is manipulating the way that we
- 1:32move our camera through scripting if
- 1:34let's say we had a system like this in
- 1:36place and so these are just some
- 1:38examples of being able to manipulate the
- 1:40camera and that's what we're going to be
- 1:41doing inside of this video so with that
- 1:43being said let's go ahead and go
- 1:45straight into the episode now that we
- 1:46understand it let's Implement camera
- 1:48manipulation inside Roblox Studio but I
- 1:50do want to emphasize that when we're
- 1:53changing the camera either through its
- 1:54properties or through scripting we want
- 1:56to do it on the local side because every
- 1:59single player has their own camera since
- 2:01what they see in the world is going to
- 2:03be unique from each other so we're going
- 2:04to get into more about that later when
- 2:06we start scripting it but as of right
- 2:08now what I want to do is introduce to
- 2:10you some properties that we can change
- 2:12with the camera and the first place to
- 2:13look is inside of starter player so I'm
- 2:16going to select this and there should be
- 2:17a category called camera right over here
- 2:20that has these properties that we can
- 2:21change for a starting player when they
- 2:23join into the game so I'm just going to
- 2:25scale this out so we can show the
- 2:27properties um two of these involve the
- 2:30zoom distance for the camera so
- 2:31basically how far away can the player
- 2:33zoom and how close in can they Zoom so
- 2:36by default the max Zoom distance is 128
- 2:39so if I were to demonstrate this to you
- 2:41I can just reduce this to let's say 20
- 2:43and I can increase the minimum Zoom
- 2:45distance to let's say 10 so now if I hit
- 2:47play then what should happen is that if
- 2:50I try to zoom out it's not going to work
- 2:52because I set the max Zoom distance to
- 2:5420 studs now if I try zooming in it's
- 2:57only going to go in as close as 10 studs
- 3:00from the player so it kind of gives a
- 3:03constraint to how far the distances are
- 3:06um with the camera and so that's uh one
- 3:08set of properties so I'm just going to
- 3:10hit backspace and just so I'm just going
- 3:11to hit backspace really quick um next
- 3:13thing is camera mode so there's only two
- 3:15options it's either classic or lock
- 3:17first person I think that one's pretty
- 3:18self-explanatory now Dev camera
- 3:21occlusion mode is essentially a way for
- 3:24the camera to handle objects that are
- 3:26obstructing the character with the
- 3:29camera's view so if I were to create a
- 3:31part just like this I'm just going to
- 3:32create like some tall structure right
- 3:34here and what I'm essentially going to
- 3:37do is hit play so what's going to happen
- 3:40is when the camera tries to deal with
- 3:43objects that are obstructing the player
- 3:45like this then it's going to zoom the
- 3:47camera into where the player is just
- 3:49like this I think you kind of notice
- 3:51what's happening here so this is what's
- 3:53happening by default but there's
- 3:55actually a second option we can change
- 3:57for the occlusion mode and that's called
- 3:59called invisicam so when I hit play now
- 4:02uh once we go into the game then instead
- 4:04of zooming into the character what it's
- 4:06going to do is it's going to set the
- 4:08transparency of the objects that's
- 4:11blocking the player to semi-transparent
- 4:13or like 0.5 or whatever you want to
- 4:15describe this as so that's what
- 4:17invisicam does and so I think this is
- 4:18something you should experiment with uh
- 4:20depending on the kind of game that
- 4:21you're creating now there's two more
- 4:23options here which is basically what
- 4:25allows the developer to set uh a fixed
- 4:29camera movement type for the user if
- 4:31they joins the game I'm going to explain
- 4:33these camera types in a little bit um
- 4:35but that's essentially some of the
- 4:36properties that we can set for um a
- 4:39starting player okay but now I want to
- 4:41get into the camera object itself and
- 4:44this is located inside of workspace so
- 4:47if I open this up then our camera should
- 4:49be right over here and there's two
- 4:51properties that I want to look at that
- 4:52are going to be important one of them
- 4:54being camera subject and the other one
- 4:56being camera type which is both under
- 4:59the camera category so to explain what
- 5:01camera type is I'm just going to hit
- 5:03test and hit play and it's basically a
- 5:07property that allows us to change what
- 5:10kind of camera that we have going for
- 5:12this specific player or ideally for all
- 5:14players that are inside of the game so
- 5:16by default it's set to custom which is
- 5:19essentially uh whatever we pick for the
- 5:22camera mode that's inside of our
- 5:23settings which by default is classic so
- 5:27classic is what allows us to move around
- 5:28freely the this is what the classic
- 5:30camera type is but then we can change
- 5:32this to something else like let's say
- 5:33attach so the way this camera goes is
- 5:37different than what we had before and if
- 5:39I were to do fixed then it's just going
- 5:41to stay in place and then if we select
- 5:44something else like orbital then it's
- 5:46going to have this weird like top down
- 5:48perspective so you can see all of these
- 5:50different types of cameras that we can
- 5:53have for our game and depending on the
- 5:55kind of game that you're creating I
- 5:56think picking one of these camera types
- 5:58is going to be pretty beneficial I um so
- 6:00that's something I wanted to show so I'm
- 6:02just going to quickly set this back to
- 6:04custom and the other property is called
- 6:05the camera subject now by default our
- 6:08camera subject is the humanoid of our
- 6:12local player so basically the subject is
- 6:15essentially the reference part or
- 6:18instance that the camera is attached to
- 6:21so we can actually change this to be a
- 6:23reference to a different part by simply
- 6:25going to our camera uh clicking on
- 6:27camera subject and then we can select
- 6:29whatever reference we want for our
- 6:32camera subject so let's say we want it
- 6:34to be the part that we created so the
- 6:36camera has now moved to be a part to be
- 6:39the camera for this uh part that we
- 6:42created because this is now our
- 6:44reference point rather than our
- 6:46character so that's a little something I
- 6:47wanted to show as well and if we want to
- 6:49revert this back I'm just simply going
- 6:50to say camera subject and then I'm going
- 6:52to click back on our humanoid so that we
- 6:55now have our reference being our
- 6:57character so with what we know right now
- 6:59we can start scripting our camera and
- 7:01what we're going to do is create a local
- 7:03script in let's say starter player and
- 7:06starter player scripts we're going to
- 7:08hit the plus sign and we're going to
- 7:09insert a local script and we're going to
- 7:11delete this code right here so the first
- 7:13thing we have to do is make reference to
- 7:15our camera by saying local camera equals
- 7:18game.or space. camera now you might
- 7:21think that this is the camera that we're
- 7:22trying to reference here but that's
- 7:24actually not correct even though there
- 7:26is a camera inside of workspace this is
- 7:29not the the right kind of camera that we
- 7:30want to manipulate because there's a
- 7:32difference between a camera and a
- 7:35current camera camera is basically the
- 7:38Studio's camera but what we want to
- 7:40manipulate is the current camera which
- 7:42is basically our local players camera so
- 7:45instead of camera we're going to say
- 7:47current camera just like this and so
- 7:50when we're manipulating the camera
- 7:51inside of a local script we want to use
- 7:53current camera okay so now that we have
- 7:55that what we can do is manipulate a
- 7:57property that camera might have like
- 7:59let's say the C frame of it and when we
- 8:01change the C frame of the camera it's
- 8:02literally going to move the camera in a
- 8:04specific point inside of the game so
- 8:08what we can do is say camera. cframe
- 8:11equals and we can just create a new
- 8:12cframe we can say cframe do new open
- 8:15close parenthesis we could just say 100
- 8:17100 and 100 so you might think that this
- 8:21would work but let me show you what
- 8:23happens if we hit play so I'm going to
- 8:24go to test and hit play and what we
- 8:27should see is the game is still running
- 8:30basically as expected without executing
- 8:32the script it seems like but the problem
- 8:34that lies here is this code actually did
- 8:38run but the thing is roblox's default
- 8:41camera system overrode this command that
- 8:43we created here and so what we need to
- 8:45do is not have roblox's um default
- 8:49camera system override our scripts when
- 8:51we make modifications to the camera and
- 8:54so what we need to do is set the camera
- 8:56type to scriptable so if you're
- 8:59remembered um for the camera there was a
- 9:01property here for camera type and
- 9:03scriptable was actually one of them so
- 9:05this is what we need to set the camera
- 9:06type to before we make any scripting
- 9:08changes to the camera so what we're
- 9:10going to do is hit stop I'm going to go
- 9:12to the local script and before we make
- 9:13the cframe change what we're going to do
- 9:15is say camera. camera type equals in
- 9:19quotations we're going to say scriptable
- 9:22just like this and I'm also going to add
- 9:25a task. weight for about 1 second so
- 9:27that the game loads in in time before we
- 9:29make this change so now if we go into
- 9:30the game and hit play then what we
- 9:32should see is that our camera's C frame
- 9:36is now located at uh the coordinates 100
- 9:40100 and 100 with X Y and Z respectively
- 9:42but we haven't changed like the angle of
- 9:45it or like where we're looking at in
- 9:47specific but this is essentially how we
- 9:49change the position of the camera inside
- 9:52of the game once we change the camera
- 9:54type to be scriptable so let's say we
- 9:56wanted to have a cutscene system where
- 9:58we have one starting point and one
- 10:00ending point for the camera to
- 10:03essentially go from the starting point
- 10:04to the ending point we can do that by
- 10:06manipulating the CF frame of the camera
- 10:08using our scriptable camera type and so
- 10:11what we can do is essentially create two
- 10:13points that go from point A to point B
- 10:16by simply just going to model I'm just
- 10:17going to insert a part over here I'm
- 10:20going to call this start and then I'm
- 10:23going to duplicate this and then move
- 10:25this somewhere that's semi far away I'm
- 10:28also going to change the the rotation of
- 10:29this just a little bit and I'm going to
- 10:31rename this one to end and so what we
- 10:34can do is have our camera's CF frame
- 10:38start here and then we can have the
- 10:40camera move into the direction of where
- 10:43the end part is over here and so that
- 10:45way we can create this sort of cinematic
- 10:47experience by going from the first part
- 10:49to the next part so what we're going to
- 10:50do inside of the local script is
- 10:52reference these two parts by dropping
- 10:54two lines and we're going to say local
- 10:56start equals game. workpace colon wait
- 10:59for Child open close parenthesis start
- 11:03and then we're going to do the same
- 11:04thing for the End by saying local end
- 11:06equals game. workspace colon wait for
- 11:10Child open and close parentheses end now
- 11:13I realized that Roblox is triggering a
- 11:15keyword here so I think we should say
- 11:17end part and start part instead of just
- 11:20start and end just like that so now what
- 11:22we're going to do is change the cframe
- 11:25of this camera to be the cframe of the
- 11:27start part so we're going to say start
- 11:30part. cframe and then what we can do is
- 11:33put a task. we for about 2 seconds and
- 11:35then we can say camera. cframe equals
- 11:39end part. cframe so if we go into the
- 11:42game hit test and hit play then it's
- 11:45going to start at this part like the
- 11:48start part C frame and then it's going
- 11:49to go to the end parts C frame just like
- 11:51that but it didn't do it in a smooth
- 11:53fashion like we literally hardcoded the
- 11:55C frame to change uh after about like 2
- 11:58seconds but what we can do is add a
- 12:01smooth transition with tween service so
- 12:04what we can do is drop two lines above
- 12:06here and say local tween service equals
- 12:10game colon get service tween service and
- 12:12then what we can do is instead of
- 12:15directly changing the C frame just like
- 12:16this I'm just going to comment this out
- 12:18I'm going to create a tween and then
- 12:20play it by saying tween service colon
- 12:24create open and close parenthesis and
- 12:26then we're going to set camera as our
- 12:29object and then we're going to add a
- 12:31tween info object so we're just going to
- 12:33create one here by saying tween info.
- 12:36new open close parenthesis we're going
- 12:38to make this last for 2 seconds and then
- 12:41uh we're going to have a table full of
- 12:43the goals that we're trying to
- 12:45accomplish with this tween which in this
- 12:47case is going to be the C frame so we're
- 12:49going to set this equal to endp part. C
- 12:53frame just like that and then we're
- 12:54going to play this tween by saying colon
- 12:57play open and close parentheses by the
- 12:59of it uh we can even get rid of these
- 13:01two lines as well we don't really need
- 13:02them and now if we go into the game and
- 13:05hit play then what we should see is that
- 13:08it did like a little smooth transition
- 13:10with tween service by having the
- 13:11starting point go to the ending point
- 13:14just like that I can even show it to you
- 13:16again by waiting for two seconds before
- 13:18the script fires so 2 seconds have
- 13:21passed and it went from the starting
- 13:22point to its ending point and so that is
- 13:25essentially how we create this sort of
- 13:27transition with camera manipul ation and
- 13:29tween service now there's two rendering
- 13:31properties I want to show you that you
- 13:33might find useful but before we do I'm
- 13:35going to disable our local script and
- 13:37I'm going to select the camera so
- 13:39there's two properties I want to show
- 13:40the first one is focus and the second
- 13:42one is field of view field of view is a
- 13:45property that essentially tells us the
- 13:48extent to which we can see the world
- 13:50through our screen and basically what I
- 13:52mean is if we change this field of view
- 13:54from 70 to let's say 100 by increasing
- 13:57it then it's going to compress the
- 13:59screen vertically so that it feels like
- 14:02we can see more of the world than we can
- 14:04actually see um and if we do the
- 14:07opposite by changing this to something
- 14:09smaller like 40 then it's going to
- 14:11expand the screen vertically outward so
- 14:14that it feels like we're zoomed in and
- 14:16we can actually see something that's
- 14:17closer so a smaller fov would be useful
- 14:20if let's say we wanted to zoom in on
- 14:22something and then uh a bigger fov would
- 14:25be cool for something like if the user
- 14:27has like a shift to Sprint system and we
- 14:29want the player to see that they are
- 14:32moving Faster by changing the fov to
- 14:34something where we can see more of the
- 14:36world so that's basically what fov is
- 14:39I'm going to set this back to 70 and the
- 14:42other property is called Focus which is
- 14:44essentially a point in the world where
- 14:47we want roblox's graphical system to
- 14:50prioritize anything it needs to render
- 14:52within this specific Focus Point versus
- 14:55anything that's farther away from this
- 14:57Focus point now by default you don't
- 15:00really have to worry about this property
- 15:01because as you can see while I'm moving
- 15:03my camera the focus is being updated
- 15:06with the cframe of the camera and
- 15:08usually the focus property is synonymous
- 15:11with the cframe camera because when we
- 15:13have the camera subject be set to let's
- 15:15say the the player's humanoid then the
- 15:18focus point is going to be on the
- 15:20character's humanoid um but if we let's
- 15:23say had a customized system where we
- 15:26have a scriptable camera type we would
- 15:28have to change this Focus property
- 15:30manually and because this is being
- 15:32updated every single frame we would have
- 15:34to use run service to update the focus
- 15:37every single frame when we're using our
- 15:41uh own scriptable camera type and that's
- 15:43something I wanted to introduce to you
- 15:45that you might want to consider using
- 15:47inside of the future okay so now I'm
- 15:48going to show you what are called
- 15:50raycast Methods and how they apply with
- 15:52the camera now I haven't made a
- 15:54dedicated tutorial on rayc casting yet
- 15:56so whatever I talk about in this episode
- 15:58I'm going to be emitting the technical
- 16:00details of the ray casting part but I
- 16:02still want to show some methods that are
- 16:04very useful with the camera that I think
- 16:05you'd want to use for your game and one
- 16:07of those methods is called get parts
- 16:10obscuring Target now basically what this
- 16:12method does is we take a specific point
- 16:15inside of the game and we want to detect
- 16:17if there's any instances that are
- 16:19blocking that uh position inside of the
- 16:22game so let's say we take this spawn
- 16:24location right here and we want to get
- 16:25the position of this so with the
- 16:27position of the spawn location we want
- 16:29to check if there's any parts that are
- 16:30blocking it from the camera but as of
- 16:32right now we can see the spawn location
- 16:35but if we were to hide behind this wall
- 16:37right here then this is going to be a
- 16:39part that is obscuring this spawn
- 16:42location's position so we can do that
- 16:45through our script using this camera
- 16:47method and so that's what I'm going to
- 16:48be showing you how to add right now so
- 16:50what we're going to do is go to our
- 16:51local script I'm going to drop two lines
- 16:54well actually first thing we're going to
- 16:55do is we're going to comment out
- 16:56everything we've had up until this point
- 16:59and I'm also going to comment out this
- 17:01task. weight statement at the beginning
- 17:02but we're going to keep the camera
- 17:03reference so here's what we're going to
- 17:05do um we're going to say local Parts
- 17:10obscuring Target equals camera colon get
- 17:15parts obscuring Target open close
- 17:18parenthesis and inside of here it takes
- 17:20two parameters one of them is cast
- 17:22points and the other one is an ignore
- 17:24list so I'm going to explain what both
- 17:25of these are so cast points is basically
- 17:28a table full of these Vector 3 positions
- 17:31that I was mentioning earlier before
- 17:32with the spawn location now you can have
- 17:34more than one position if you want but
- 17:36I'm going to say for the sake of this
- 17:37example this spawn location position
- 17:39right here so what we're going to do is
- 17:41drop a line at the beginning and we're
- 17:43going to say local cast points equals
- 17:47game. workpace colon wait for child
- 17:51spawn location and then we're going to
- 17:53wrap this with uh curly brackets to make
- 17:56this a table so this is our cast points
- 17:58and we can pass this in as the first
- 18:00parameter so we're going to say cast
- 18:01points just like this and now the second
- 18:02thing is an ignore list an ignore list
- 18:05is basically a table full of instances
- 18:08that we don't want to include uh for
- 18:10when we're detecting if there's a part
- 18:13that's obscuring the cast Point position
- 18:15that we're interested in so let's say
- 18:17for this part right here if we add this
- 18:19to the ignore list then we can still see
- 18:22this part's location because we added
- 18:24this to the ignore list so we can do
- 18:26that in our local script by saying local
- 18:28a nor list equals open and close curly
- 18:31braces and then we can add that inside
- 18:34of our second argument just like this
- 18:36now there is going to be a problem with
- 18:38this ignore list so now what I'm going
- 18:40to do is I want to be able to
- 18:42demonstrate this inside of Roblox studio
- 18:43and the best way we can do this is by
- 18:45using run service so that we can get a
- 18:47frame by frame uh representation inside
- 18:49of the output so here's what we're going
- 18:51to do we're going to say local run
- 18:55service equals game get service run
- 18:58serice
- 18:59run service just like this and what I'm
- 19:01going to do is say run
- 19:05service do hardbeat colon connect
- 19:08function open close parentheses enter
- 19:10and I'm going to take this line and
- 19:12paste it inside of here now what I'm
- 19:14going to do is check if the number of
- 19:16instances that we get that are obscuring
- 19:18the target is greater than zero so that
- 19:20tells us if there is at least one part
- 19:22that's blocking our Target so we're
- 19:24going to say if uh pound symbol parts of
- 19:27scaring Target is greater than Z then
- 19:29we're going to print
- 19:32something is blocking the Target and
- 19:36then what I'm going to do is print out
- 19:38all the parts that are blocking the
- 19:39target so we're going to say for I comma
- 19:42part in I pairs open and close
- 19:45parenthesis Parts obscuring Target do
- 19:48and then we're going to print the part
- 19:50itself and then to separate every single
- 19:53time we check this we're we're just
- 19:54going to separate this using uh a couple
- 19:56dashes Okay so here's what we have so
- 19:59far let's go into the game and hit play
- 20:01now there is going to be a problem with
- 20:03this so right
- 20:07now oh hold on the script is not working
- 20:10oh my bad there was a typo on my end um
- 20:12so we're supposed to say spawn location.
- 20:14position because this is a table full of
- 20:17vector 3 values we're not putting in the
- 20:20instance themselves so now if we go into
- 20:22the game and hit play there should be a
- 20:24problem here and I'm going to show you
- 20:26why so it says in the output that there
- 20:27is something that's blocking the target
- 20:29which is the spawn location itself
- 20:31that's because for the cast points we're
- 20:33interested in the position of the spawn
- 20:35location not the spawn location itself
- 20:38so what we need to do is add the spawn
- 20:40location to the ignore list so that it's
- 20:43not counted when we are looking for
- 20:45parts that are scaring it so I'm just
- 20:47going to copy this line here and I'm
- 20:48going to paste it inside of the ignore
- 20:50list and now what we're going to do is
- 20:52hit play so the spawn location should
- 20:54not be included with any part that's
- 20:56obscuring it um so now if we look at
- 21:00what's happening here uh what I'm going
- 21:01to do is block the spawn location using
- 21:05this part and so now it's going to say
- 21:06that something is blocking the target
- 21:08which is um this part right here uh I
- 21:10can even stand in front of it and
- 21:12there's going to be a bunch of hats and
- 21:14accessories from my avatar that's
- 21:16blocking this spawn location as well and
- 21:18it's being displayed in the output here
- 21:20every single frame and so this is
- 21:21essentially what this function does and
- 21:23you can definitely find usefulness with
- 21:25this function so this is something I
- 21:26wanted to introduce to you that you
- 21:28might that you might want to use for
- 21:29your games okay the next method I want
- 21:30to show you is called world two screen
- 21:33point now the idea behind this method is
- 21:35that we want to take a vector 3 position
- 21:39of whatever part that's inside of the
- 21:40game and we want to convert that to a 2d
- 21:44position or a vector 2 value that's
- 21:46going to be displayed on our screen uh
- 21:49that's relative to the camera as well so
- 21:51let's say we had this part that's right
- 21:52over here and we wanted to take that
- 21:54Vector 3 position of this part and
- 21:57convert it to a screen position that's
- 21:59going to be displayed on our screen so
- 22:02that's essentially what this function is
- 22:03going to do now instead of coding this
- 22:05up I'm going to show you a really
- 22:07practical example of this so that you
- 22:09get an idea of what I'm talking about
- 22:11okay so this video demonstrates what I'm
- 22:12talking about and essentially What's
- 22:14Happening Here is that there's all these
- 22:16coins that are scattered across the map
- 22:17and when the player picks up the coin
- 22:20then it's going to convert the vector 3
- 22:23position of that coin and give us a 2d
- 22:26position of that part that's on our
- 22:29screen that's relative to the camera and
- 22:31then it's going to create this uh image
- 22:33label of a coin and display it at that
- 22:35position and then it's just going to fly
- 22:37off to the screen once it's done but
- 22:39this is essentially what I'm talking
- 22:40about when it comes to converting a 3D
- 22:43point and converting it to a 2d point on
- 22:46the screen and this is a really
- 22:47practical example of using this function
- 22:49which I want to give credit to my admin
- 22:51for creating this and also for creating
- 22:52the script as well so essentially it
- 22:54returns so essentially World 2 screen
- 22:57Point takes one parameter which is uh
- 22:59the position of the coin that was being
- 23:01picked up and then it returns a vector
- 23:04that gives us the X and Y components of
- 23:06the 2D screen and this is a Boolean that
- 23:09tells us whether this actually fits on
- 23:11the screen or not and then it creates
- 23:13the coin image label and shows it on
- 23:14screen so then as you can see we take a
- 23:16udm 2 value and we use the vectors X and
- 23:19Y component to change the position uh of
- 23:22the the image label for the 2D screen so
- 23:25this is a little practical example I
- 23:26wanted to show and I hope that this gave
- 23:27you insight into using this function now
- 23:30there is another method called World 2
- 23:32viewport frame but this is literally the
- 23:34same exact method as World 2 screenpoint
- 23:38but there's only one difference and that
- 23:41is we're not taking into account the guy
- 23:43inset that is built into every single
- 23:45Roblox game unless the developer
- 23:47specifies not having this GUI inset and
- 23:50what I mean by this GUI inset is that
- 23:52Roblox reserves a specific uh amount of
- 23:56space on the top of the screen for their
- 23:58own own customized UI like these buttons
- 24:00over here and so with this function over
- 24:02here we're essentially ignoring this top
- 24:04part here when we're using World 2
- 24:06viewport frame so that's the only
- 24:08difference and I think it's a pretty
- 24:09nice distinction uh from the two
- 24:11functions so depending on which one you
- 24:13use I hope you find practical use with
- 24:15these functions and I hope you found
- 24:17this part to be informative so for
- 24:19today's challenge I want you to create
- 24:20this spectate mode GUI system where we
- 24:24have a button here that says spectate
- 24:25and if we click on it then it's going to
- 24:27show this little panel here that
- 24:30displays what player we're currently
- 24:32spectating and we can click these arrows
- 24:35to flip to different players perspective
- 24:38so that we can spectate them so if I
- 24:39press this right button then it's going
- 24:41to change the camera to reflect on this
- 24:44player's humanoid instead of my humanoid
- 24:47and then if I were to uh flip it back to
- 24:50my character then it's going to change
- 24:51my camera to reflect my character's
- 24:54humanoid and so we can do the same thing
- 24:56going reverse and we can do the same
- 24:57thing going forward so this is what I
- 24:59want you to create for this Challenge
- 25:01and for the sake of time so once you've
- 25:03given this a try then we can come back
- 25:04and dive deeper into this spectate mode
- 25:07GUI so for the sake of time I'm not
- 25:09going to be coding this with you step by
- 25:10step but I will show you what I did with
- 25:13my code so that hopefully it can give
- 25:14you a better understanding of how this
- 25:16system works so what we have here on the
- 25:19right side is a spectator screen GUI so
- 25:22if I open this then there's going to be
- 25:24a local script a frame and a button so
- 25:27the spectate button is the button down
- 25:29here and then spectate frame is the the
- 25:32little panel that shows the player's
- 25:33name that we're currently spectating and
- 25:36the left and right button so it can flip
- 25:38through different players so if I open
- 25:39this up there's a left button a right
- 25:41button and a text label that tells us
- 25:44the player's name that we're currently
- 25:45spectating so I'm just going to disable
- 25:47this and now we're going to analyze the
- 25:50local script behind it so basically what
- 25:52we have going on here is a player list
- 25:55that gives us a table of all the players
- 25:58that can spectate and then this position
- 26:00is the index value of the player that
- 26:03we're going to be viewing inside of the
- 26:05spectate mode GUI and there's two
- 26:08functions here so the first one is
- 26:09update player list this one just takes
- 26:11our player list and updates it with all
- 26:13the players that are currently available
- 26:14and then update camera is what allows us
- 26:17to change the camera subject of our
- 26:20current camera to whatever the player
- 26:23that we're currently spectating is to
- 26:26whatever player we're currently
- 26:27spectating and we get their humanoid
- 26:29with that and then we change the the
- 26:31text of the player name of that as well
- 26:33okay so once we press the spectate
- 26:35button so this button down here then
- 26:38it's going to update the player list
- 26:39automatically and it's going to give a
- 26:41check as to whether we are currently
- 26:43spectating and if we are then we're
- 26:44going to set that equal to true we're
- 26:46going to make the frame visible and
- 26:48we're also just as a safety measure
- 26:50we're going to make the character not be
- 26:52able to move while we're spectating and
- 26:54we're going to set the position
- 26:55automatically to one and then we're
- 26:58going to use update camera with the
- 27:01player that lies in the the position of
- 27:04one and if we're not spectating then
- 27:06we're just going to let the player move
- 27:07we're going to disable the frame and
- 27:09we're going to let the player have
- 27:11control again since we're not spectating
- 27:12anyone okay so that is what happens when
- 27:15we press spectate button so if we press
- 27:17the right button so if I were to load up
- 27:20the frame again it's this button right
- 27:22over here it's going to check whether we
- 27:24are spectating and if we're not then
- 27:25it's just going to return the function
- 27:27we're going to update the list again and
- 27:29then essentially What's Happening Here
- 27:31is that we're going to be updating the
- 27:33position before we update our players
- 27:36camera to that uh position inside of the
- 27:38player list so essentially What's
- 27:40Happening Here is that and if this
- 27:42increment is greater than the size of
- 27:45the player list then we're going to be
- 27:46going out of bound and we don't want to
- 27:48do that so what we do is we set the
- 27:51position back to one so we're
- 27:53essentially resetting it and if we're
- 27:55not going out of bound then we're just
- 27:56going to Simply take the position and
- 27:59add one to it so that we're flipping
- 28:00through the players of the player list
- 28:03and so that's what we do when we update
- 28:04the camera and we're essentially doing
- 28:06the same thing with the left button
- 28:08where we press it except this time
- 28:10instead of going forward we're going
- 28:13backwards so we're going to take the
- 28:15position and we're going to subtract it
- 28:16by one and we're going to see if this is
- 28:18less than one because if we have a value
- 28:21of zero well there's no such thing as an
- 28:23index value of zero so this is not going
- 28:25to work so if this is the case then
- 28:27we're going to set the position to the
- 28:30size of the player list so we're going
- 28:31to start backwards and if that's not the
- 28:33case then we're just simply going to
- 28:35decrement the position by subtracting it
- 28:37by one and then once again we're going
- 28:40to be updating the camera and that is
- 28:42essentially the rundown of this spectate
- 28:45GUI script and I hope that this
- 28:48explanation has helped you with
- 28:51understanding how this system is created
- 28:53so that's pretty much going to be it for
- 28:54this episode if you found this video to
- 28:56be very helpful then I encourage you to
- 28:58leave a like on this video And subscribe
- 29:00to the channel if you haven't already uh
- 29:02I would also like to give a shout out to
- 29:04all of my patreon members for supporting
- 29:06the work that I do and providing me with
- 29:08continuous support as well um I
- 29:09appreciate them a lot and if you want to
- 29:11have access to my scripts get early
- 29:12access to the videos then I encourage
- 29:14you to become a patreon member as well
- 29:16um your support would be very
- 29:18appreciative and if there and if you're
- 29:19still confused about some of the
- 29:20concepts that we talked about like C
- 29:22frames then I will have a link to that
- 29:24video for you right here to watch so go
- 29:26ahead and watch that if you haven't
- 29:27already also you can check out the other
- 29:29videos that are in my Advanced scripting
- 29:31tutorial guide and with that being said
- 29:33that's going to conclude this episode I
- 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.