Proximity Prompt - Roblox GUI Tutorial #12 — Transcript
Full transcript
- 0:00okay Newbert I I know you're mad at me
- 0:02right now but I did not steal the last
- 0:05cookie from the cookie jar last night
- 0:07okay you have to believe me on this bro
- 0:09wait what are you
- 0:12saying yeah okay so we're coming to a
- 0:14general consensus why don't I just Open
- 0:16this gate so that you can come out and
- 0:17then we can shake hands like adults how
- 0:19does that sound does that sound fair to
- 0:23you okay so I'm about to open the door
- 0:26so I'm going to open the jail cell uh
- 0:28I'm just going to be doing this and then
- 0:30once you come out let's just be civil
- 0:31about this okay so I'm just going to
- 0:33open the door uh just like so and
- 0:37oh oh Newbert Newbert Newbert
- 0:41Newbert once you're fixated on something
- 0:43you just can't back out of it can't you
- 0:46oh my goodness today's video is going to
- 0:48be about proximity prompts which are
- 0:50basically these interactive popups that
- 0:52you see inside of the game that you've
- 0:54probably seen in many other Roblox games
- 0:56in the past where you press a certain
- 0:58key or a certain button to interact with
- 1:01whatever it is we're trying to interact
- 1:02with in the game and you can also call
- 1:04this uh the Press e to interact
- 1:06functionality that Roblox has provided
- 1:08to us in which I'm going to be teaching
- 1:10you how to implement inside of this
- 1:11video so with that being said let's now
- 1:14go ahead and go straight into
- 1:15implementing now that we understand it
- 1:17let's Implement proximity prompts inside
- 1:19of Roblox studio so there's a couple of
- 1:21things we need to know about proximity
- 1:23prompts before we're able to like see
- 1:25them inside of our game uh but the first
- 1:27thing we're going to do is insert a part
- 1:30so that we can attach our proximity
- 1:31prompt to that part because we can't
- 1:34just have a proximity prompt on its own
- 1:36it needs to be attached to a part or I
- 1:38believe most 3D objects that are
- 1:40contained within the game but we're just
- 1:41going to be inserting a part so I'm
- 1:43going to go to model and I'm going to
- 1:44click on part now with this part I'm
- 1:46just going to scale this up just like so
- 1:49and what I'm also going to do is rename
- 1:51this part to proximity part just like
- 1:55this and then I'm going to hit the plus
- 1:56sign next to the proximity part and I'm
- 1:58going to insert a proximity prompt which
- 2:01should look like this so now that we
- 2:04have our proximity prompt there's a few
- 2:05properties that we need to understand
- 2:07here when we're looking at this
- 2:09proximity prompt once we interact with
- 2:11it now if I were to just go into the
- 2:13game and hit test then we're able to
- 2:15walk up to the part and we can see our
- 2:17basic proximity prompts over here so by
- 2:20default it uses the E key and there is
- 2:23no object text but there is an action
- 2:25text that says interact here so if I
- 2:27press e then it does interact with it
- 2:29but it doesn't do anything right now we
- 2:30need to add functionality to it but
- 2:32before we do that I'm going to hit stop
- 2:34and I'm going to show you uh some things
- 2:36we can do to change this proximity
- 2:38prompt so the first thing to consider is
- 2:40two things first is the keyboard key
- 2:42code and then the second one is the
- 2:44GamePad key code so uh if you're playing
- 2:46on PC then we need to consider the
- 2:48keyboard key code that uh you should
- 2:50press in order to activate this
- 2:53proximity prompt which by default it's e
- 2:55so if we select this then we can select
- 2:57uh a bunch of different keys that we can
- 2:59use rather than e but just by default
- 3:01we're going to set it to e and then the
- 3:03second thing is the gam pad key code so
- 3:05if you're playing on Xbox or PS4 then
- 3:08this is what is going to be replaced for
- 3:10the GamePad key code instead next thing
- 3:12is the object text and the action text
- 3:15both of these are two different things
- 3:16and I'm going to help you understand the
- 3:18difference between these two so object
- 3:20text is basically the part or object
- 3:22that the proximity prompt is currently
- 3:24in that we're trying to interact with so
- 3:27you can think of object text as what is
- 3:30it that we're interacting with and then
- 3:32we have action text here which is
- 3:33basically the action that we're going to
- 3:35be taking with this object that we're
- 3:37looking at right here which is this
- 3:38proximity prompt so it can either be
- 3:41like what action are we going to take or
- 3:43it could also just be what do you want
- 3:44the player to do once you activate this
- 3:47part so for the object text what I'm
- 3:49going to do is just call this proximity
- 3:52part and then for the action text we
- 3:54could just say click just like this just
- 3:56to make it something different and then
- 3:57if we go to test and then hit play then
- 3:59what we should see is if we walk up to
- 4:02it then it's going to first say the
- 4:04object text which is going to be the
- 4:06proximity part and then what's in white
- 4:09this is going to be the action text
- 4:11right here and then on the left side
- 4:13it's going to show our key that we have
- 4:15to press in order to interact with it
- 4:16which is e so now we've customized our
- 4:19proximity prompt just a little bit but
- 4:20if we try to interact with it it's still
- 4:22not going to work because this is
- 4:24something we need to script ourselves so
- 4:26that is basically some key aspects to
- 4:29proximity pars that I wanted to show you
- 4:31so what I'm going to do is I'm going to
- 4:32go to our proximity part I'm going to
- 4:34click on the plus sign and I'm going to
- 4:35insert a script so within the script
- 4:38what I'm going to do is first locate our
- 4:39proximity prompt by saying local
- 4:42proximity prompt equals script. parent.
- 4:46proximity prompt just like this and
- 4:48there's two events for proximity prompts
- 4:50that we can use the first one is going
- 4:52to be called proximity
- 4:55prompt. triggered uh colon connect
- 4:59function open close parenthesis enter
- 5:01now what this uh event does is it
- 5:04basically activates when we interact
- 5:07with the proximity prompt by pressing e
- 5:09so there's one argument that gets ped
- 5:12here which is the player who triggers
- 5:14this proximity prompt so I'm just going
- 5:16to pass this in as a player and what we
- 5:18can do just for a simple example is
- 5:20print the player's name just like so
- 5:23whenever we interact with the proximity
- 5:24prompt so if we go into the game and hit
- 5:25play and we walk up to the proximity
- 5:27prompt and press e on it then what
- 5:29should see in the output is the name of
- 5:31the player who interacted with it which
- 5:33in this case is me braw battle now
- 5:36there's something else we can do with
- 5:37this proximity prompt and that is adding
- 5:39a hold duration to it uh so that we
- 5:42don't just press the key and then it'll
- 5:44automatically trigger so that's with the
- 5:46use of hold duration down here which is
- 5:49in seconds so if I put this for let's
- 5:51say 2 seconds then it's going to add a
- 5:54hold duration before it actually
- 5:56triggers the proximity prompt so now if
- 5:58we go into the game and try this out for
- 6:00ourselves so we can't press it anymore
- 6:03but instead we have to hold it for 2
- 6:05seconds before it triggers it once down
- 6:08here by printing out braw battle so that
- 6:10is a little something I wanted to add
- 6:12there just for more functionality
- 6:13another thing we can do is add a hold
- 6:16down functionality to this proximity
- 6:18prompt if that makes sense like you
- 6:19basically hold down the proximity prompt
- 6:22and then after a certain period of time
- 6:23when you let go then it's basically
- 6:25going to stop executing the proximity
- 6:26prompt and we're going to be doing this
- 6:28by using another event called triggered
- 6:32ended so if I drop two lines down here
- 6:33and say proximity
- 6:36prompt. triggered ended just like this
- 6:39colon connect function open close
- 6:41parenthesis and we're going to pass in
- 6:43the player once again and then we're
- 6:44going to hit enter so uh what we can do
- 6:46is just say player has let go of the
- 6:50proximity prompt just like this and if
- 6:53we go inside of the game and then hit
- 6:55play then what we should see happening
- 6:58is if we activate this proximity prompt
- 7:01by holding e for two seconds then it's
- 7:02going to print out my name I still have
- 7:04the E key uh held down on the keyboard
- 7:06but once I let go then it's going to say
- 7:08player has let go of the proximity
- 7:10prompt and now we're able to um use this
- 7:12proximity prompt again so that is
- 7:14basically how we hold down quote unquote
- 7:17a proximity prompt and you might find
- 7:19this to be useful if you ever wanted to
- 7:21try and do this inside of your own game
- 7:23if you're wondering if we can do this
- 7:24local sided yes we can and it's pretty
- 7:26easy actually so what we're going to do
- 7:28is we're going to go to our script and
- 7:29we're just going to quickly disable this
- 7:31I'm going to go to uh starter player and
- 7:34I'm going to insert a local script
- 7:35inside of starter player scripts just
- 7:37like this it doesn't have to
- 7:38specifically be here but just as as an
- 7:40example this is where I'm going to put
- 7:41the local script and the first thing I'm
- 7:43going to do is locate the proximity
- 7:45parts so I'm going to say local
- 7:48proximity part equals game. workpace
- 7:51colon wait for child proximity part and
- 7:54then I'm going to locate the proximity
- 7:56prompt by saying local proximity prompt
- 8:00equals proximity part colon wait for
- 8:02child proximity prompt just like that
- 8:04and then I'm going to say proximity
- 8:06prompt dot triggered colon connect
- 8:09function open close parenthesis and then
- 8:11we're going to pass in the player
- 8:12although you could also just refer to
- 8:14the local player since this is a local
- 8:17script now but we're just going to pass
- 8:18in the player argument here just like so
- 8:21and just as a little example what we're
- 8:22going to do is I'm going to add a remote
- 8:24event inside of replicated storage send
- 8:27this over to the server so that the
- 8:28player who triggered this proximity
- 8:31prompt will get their health be reduced
- 8:32by 10 just to like show you a practical
- 8:34example so what I'm going to do is hit
- 8:36the plus sign I'm going to insert a
- 8:38remote event just like this and I'm
- 8:40going to say take damage just like that
- 8:43and I'm going to locate this inside of
- 8:45replicated storage so I'm going to say
- 8:47local uh take damage equals game.
- 8:51replicated storage colon wait for child
- 8:53take damage just like this and then I'm
- 8:55going to say take damage fire server
- 8:57just like that and now I'm going to
- 8:59insert insert a script inside of the
- 9:01server script service I'm going to go
- 9:02back to the local script and just copy
- 9:04our take damage reference and paste it
- 9:06in here and then I'm going to say take
- 9:08damage. ons server vent connect function
- 9:12open close parenthesis player just like
- 9:14this and then I'm going to basically
- 9:16just say player.
- 9:19character. humanoid do Health minus
- 9:23equals 10 just like this just as a very
- 9:25simple example basically what this is
- 9:27going to do is every time we activate
- 9:29the proximity prompt on the local side
- 9:32then it's basically going to get rid of
- 9:3410 HP from our character every single
- 9:37time we interact with it so what I'm
- 9:39going to do is I'm actually going to get
- 9:40rid of the whole duration so I'm going
- 9:42to make this zero and I'm going to go
- 9:44and hit play so once we interact with
- 9:46this proximity pumpt by hitting it once
- 9:49and if I go to the client or sorry the
- 9:51server then it's going to say that my
- 9:54character's Health was reduced by 10 so
- 9:57if I press it twice and I go to to the
- 9:59server then it's going to keep reducing
- 10:01it by 10 every single time so I'm just
- 10:03going to like spam this and then as you
- 10:05can see I'm like basically almost dead
- 10:06just by doing this and if I keep going
- 10:08then I'm basically dead so that's like a
- 10:10little functionality for local sided
- 10:12scripting for proximity prompts if you
- 10:14ever found this to be useful not just
- 10:16for this health system but for like
- 10:18basically anything you could also do
- 10:20this in the server side as well so don't
- 10:21feel like it's restricted to just local
- 10:24side or server side it just depends on
- 10:25your preference but there are some
- 10:27instances where it will be useful to do
- 10:28it on the client side okay so I've seen
- 10:30this problem happen a lot with proximity
- 10:32prompts where it just doesn't show up
- 10:34when you try interacting with it within
- 10:36the game and one of the most famous
- 10:38examples is if we let's say had a part
- 10:41that was too wide like this and we had
- 10:45the proximity prompts that was still
- 10:46contained within this part so if I were
- 10:49to go into the game and hit play and we
- 10:50walk up to and try to interact with it
- 10:52then it's not going to show up because
- 10:54it's located in the center of the part
- 10:56that we're trying to interact with
- 10:58rather than being anywhere inside of
- 11:01this part right here and so this is a
- 11:02common problem that people have when it
- 11:04comes to using proximity prompts in
- 11:06their game they're actually is a
- 11:07solution to this by being able to select
- 11:10which area of a part that you can have
- 11:13this proximity prompt in for more
- 11:15accurate interaction with the part that
- 11:17you're trying to interact with and that
- 11:19is with the use of attachments which I
- 11:21actually haven't talked about on my
- 11:22channel yet but I'm going to be showing
- 11:24you the basics of it in this video so
- 11:26that you can use it for your proximity
- 11:27prompts so I'm just going to hit stop
- 11:29right here an attachment is just simply
- 11:31a point that is contained within a part
- 11:35so here's what an attachment looks like
- 11:37if we were to go to the proximity prompt
- 11:38and we hit the plus sign and we inserted
- 11:41a attachment it's going to look like
- 11:42this so once we insert this attachment
- 11:45and select it then we can see this
- 11:47little Green Dot right here with two
- 11:49axes going on the X Direction and One
- 11:51going on the y direction now this is
- 11:54basically where we're going to put our
- 11:56proximity prompt so that we can have a
- 11:57more accurate location
- 11:59for where we want the player to interact
- 12:01with this proximity prompt so what I'm
- 12:02going to do is I'm going to go to home
- 12:04and I'm going to select the move tool
- 12:06and then I'm going to move the
- 12:08attachment this way so that we can have
- 12:11it over here and let's say this was a
- 12:13door then I would probably have it
- 12:14somewhere that's over uh let's say here
- 12:18this is basically where we're going to
- 12:19have our proximity prompt so now what
- 12:21I'm going to do is I'm going to take our
- 12:23proximity prompt in the Explorer and I'm
- 12:24going to drag it inside of the
- 12:26attachment just like this and what I'm
- 12:28now going to do is reenable our script
- 12:31here that's inside the proximity prompt
- 12:33and I'm going to relocate our proximity
- 12:36prompt so it's going to be script.
- 12:38parent.
- 12:39attachment just like this and then it's
- 12:42going to be the proximity prompt just
- 12:44like so so now if we go uh hit test and
- 12:47hit play then what we should see inside
- 12:49of the part that the proximity prompt is
- 12:51now over here because it is contained in
- 12:54the attachment where we specified in
- 12:56this part so this is very useful if you
- 12:58want to specify a specific location of
- 13:01where you want to use this proximity
- 13:03prompt rather than just have it be in
- 13:05the center of the part that it's
- 13:06attached to by default so if we now
- 13:09interact with this then it's going to
- 13:10print out my name at the bottom when I
- 13:12let go of e then it's going to say
- 13:13player has let go of the proximity
- 13:15prompt and that is basically how we use
- 13:17attachments to solve this problem that a
- 13:19lot of developers do face with proximity
- 13:21prompts so Roblox has another property
- 13:23for us to use with proximity prompts and
- 13:26that is called exclusivity which
- 13:28basically tells tells us like how many
- 13:31proximity prompts do we want to show on
- 13:33screen if we're close by to them or if
- 13:35we want to just show one proximity
- 13:37prompts one at a time just so that we
- 13:39don't have a bunch of proximity prompts
- 13:41shown at the same time within the same
- 13:43distance that's what exclusivity does
- 13:45for us and I'm going to show you the
- 13:46difference between all three settings
- 13:48here which the first one by default is
- 13:50called one per button but just to make
- 13:52things simple I'm actually going to take
- 13:54the attachment and what I'm going to do
- 13:56is I'm going to duplicate it and then
- 13:58move it this way like this and I'm also
- 14:00going to duplicate it one more time and
- 14:02then move it upward just like this so
- 14:03now we have three attachments with three
- 14:06proximity prompts in them so I'm just
- 14:08going to select all of them and I'm
- 14:10going to click on the drop down I'm
- 14:11going to first show you always show
- 14:14which I think is the most
- 14:15self-explanatory one so if we hit play
- 14:17then what we should see is basically all
- 14:20of the proximity prompts showing at the
- 14:23exact same time as long as I'm within
- 14:25the range for this proximity prompt
- 14:27which we can specify with the max
- 14:30activation distance which is 10 studs so
- 14:32all of them show at the exact same time
- 14:35but there's a way we can change the
- 14:36exclusivity of these proximity prompts
- 14:38so if we hit stop then I'm going to show
- 14:40you the other ones so the next one is
- 14:43called one globally which basically only
- 14:46shows one proximity prompt at a time if
- 14:48we were to go inside of here then it's
- 14:50basically only going to show one
- 14:52proximity prompt and it's not going to
- 14:53show all three of them at the same time
- 14:55so that's what one globally means but
- 14:57now the last one this one's going to be
- 14:59a little tricky this one is called one
- 15:01per button which basically means that
- 15:04it's going to exclusively show a
- 15:07proximity prompt if two proximity
- 15:09prompts or more have the same exact key
- 15:12that's contained within it so what I'm
- 15:14talking about is for all of these all of
- 15:17them use the E key to activate it but if
- 15:20I had this third attachment let's say
- 15:23this one right here if we change the
- 15:24keyboard key code to something different
- 15:27like let's say r
- 15:29and if we now go into the game and hit
- 15:31play then what we should see is
- 15:33basically a proximity prompt here that
- 15:35says we can press e but also it shows
- 15:38the r key that we can press as well but
- 15:40it's not showing both of the E proximity
- 15:43prompts because we said it to be one per
- 15:45button I hope like this has made sense
- 15:47to you where it's like if we have one
- 15:49per button then it's only going to show
- 15:50proximity prompts of having one
- 15:52proximity prompt per button one of them
- 15:55being R and one of them being e but if
- 15:57this was let's say one GL globally then
- 15:59it doesn't matter what key it is because
- 16:01it's still going to show one proximity
- 16:03prompt no matter what so that's
- 16:05basically how exclusivity works and I
- 16:07hope that you found this part to be
- 16:08useful so for this last part of the
- 16:10video I want to quickly address the
- 16:11difference between a proximity prompt
- 16:13and a click detector now a click
- 16:16detector is basically roblox's old way
- 16:18of being able to interact with objects
- 16:21inside of the game so if I were to show
- 16:24you what this looks like let's insert a
- 16:26click detector inside of the proximity
- 16:28prompt and let's hit play so if I were
- 16:31to hit play then what we should see is
- 16:33this icon change inside of our Mouse
- 16:36where it shows that we are able to click
- 16:38on this part now this is the only
- 16:40functionality that this click detector
- 16:42does it allows us to click this object
- 16:45that's contained within the game and
- 16:46that's basically all this does so it's
- 16:48pretty simple and it's pretty primitive
- 16:50compared to what we have now with
- 16:52proximity prompts so you can use click
- 16:54detectors in your game if you want but
- 16:56proximity prompts kind of supersede the
- 16:59functionality of Click detectors and you
- 17:00don't need click detectors anymore but
- 17:02there can be some use cases of when you
- 17:04would decide to use click detectors over
- 17:06proximity prompts so that is kind of a
- 17:09little explanation that I can give with
- 17:11click detectors now if you want to make
- 17:12this click detector functional I can
- 17:14quickly add a script and I'm going to uh
- 17:17say script. parent and there's only one
- 17:20event that's useful which is mouse click
- 17:23colon connect function open close
- 17:26parenthesis and then we pass in the
- 17:28player clicked on it just like we did
- 17:30with proximity prompts and then we can
- 17:31print out player clicked on the part and
- 17:34then if we were to go into the game and
- 17:36hit play then what we should see is if
- 17:38we click on the part then it's going to
- 17:40say player clicked on the part and that
- 17:41is pretty self-explanatory one last
- 17:43thing is the max activation distance
- 17:45kind of like proximity prompts where
- 17:46it's like how far away does it take for
- 17:48us to actually click on this part or
- 17:50interact with it and things like that
- 17:52and so that is basically the difference
- 17:54between proximity prompts and click
- 17:55detectors and it's kind of a matter of
- 17:57preference of which one you decide to to
- 17:58use for your Roblox game so that is
- 18:01basically going to be it for this
- 18:02episode and I hope you enjoyed this
- 18:03tutorial on proximity prompts so if you
- 18:06want to learn more about interacting
- 18:07with parts in the game using guis then I
- 18:10encourage you to watch my billboard GUI
- 18:13tutorial that I will have for you right
- 18:14here on screen but with that being said
- 18:16that's basically going to be it for this
- 18:17episode I hope you enjoyed it and I will
- 18:19see you in the next one take care
About this transcript
This page contains the full transcript of Proximity Prompt - Roblox GUI Tutorial #12 by BrawlDev, generated from the public captions YouTube serves with the video. The transcript has 3,910 words across 521 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.