YouTube2Text

Proximity Prompt - Roblox GUI Tutorial #12 — Transcript

by BrawlDev · 3,910 words · 521 segments · language en · Watch on YouTube

Full transcript

  1. 0:00okay Newbert I I know you're mad at me
  2. 0:02right now but I did not steal the last
  3. 0:05cookie from the cookie jar last night
  4. 0:07okay you have to believe me on this bro
  5. 0:09wait what are you
  6. 0:12saying yeah okay so we're coming to a
  7. 0:14general consensus why don't I just Open
  8. 0:16this gate so that you can come out and
  9. 0:17then we can shake hands like adults how
  10. 0:19does that sound does that sound fair to
  11. 0:23you okay so I'm about to open the door
  12. 0:26so I'm going to open the jail cell uh
  13. 0:28I'm just going to be doing this and then
  14. 0:30once you come out let's just be civil
  15. 0:31about this okay so I'm just going to
  16. 0:33open the door uh just like so and
  17. 0:37oh oh Newbert Newbert Newbert
  18. 0:41Newbert once you're fixated on something
  19. 0:43you just can't back out of it can't you
  20. 0:46oh my goodness today's video is going to
  21. 0:48be about proximity prompts which are
  22. 0:50basically these interactive popups that
  23. 0:52you see inside of the game that you've
  24. 0:54probably seen in many other Roblox games
  25. 0:56in the past where you press a certain
  26. 0:58key or a certain button to interact with
  27. 1:01whatever it is we're trying to interact
  28. 1:02with in the game and you can also call
  29. 1:04this uh the Press e to interact
  30. 1:06functionality that Roblox has provided
  31. 1:08to us in which I'm going to be teaching
  32. 1:10you how to implement inside of this
  33. 1:11video so with that being said let's now
  34. 1:14go ahead and go straight into
  35. 1:15implementing now that we understand it
  36. 1:17let's Implement proximity prompts inside
  37. 1:19of Roblox studio so there's a couple of
  38. 1:21things we need to know about proximity
  39. 1:23prompts before we're able to like see
  40. 1:25them inside of our game uh but the first
  41. 1:27thing we're going to do is insert a part
  42. 1:30so that we can attach our proximity
  43. 1:31prompt to that part because we can't
  44. 1:34just have a proximity prompt on its own
  45. 1:36it needs to be attached to a part or I
  46. 1:38believe most 3D objects that are
  47. 1:40contained within the game but we're just
  48. 1:41going to be inserting a part so I'm
  49. 1:43going to go to model and I'm going to
  50. 1:44click on part now with this part I'm
  51. 1:46just going to scale this up just like so
  52. 1:49and what I'm also going to do is rename
  53. 1:51this part to proximity part just like
  54. 1:55this and then I'm going to hit the plus
  55. 1:56sign next to the proximity part and I'm
  56. 1:58going to insert a proximity prompt which
  57. 2:01should look like this so now that we
  58. 2:04have our proximity prompt there's a few
  59. 2:05properties that we need to understand
  60. 2:07here when we're looking at this
  61. 2:09proximity prompt once we interact with
  62. 2:11it now if I were to just go into the
  63. 2:13game and hit test then we're able to
  64. 2:15walk up to the part and we can see our
  65. 2:17basic proximity prompts over here so by
  66. 2:20default it uses the E key and there is
  67. 2:23no object text but there is an action
  68. 2:25text that says interact here so if I
  69. 2:27press e then it does interact with it
  70. 2:29but it doesn't do anything right now we
  71. 2:30need to add functionality to it but
  72. 2:32before we do that I'm going to hit stop
  73. 2:34and I'm going to show you uh some things
  74. 2:36we can do to change this proximity
  75. 2:38prompt so the first thing to consider is
  76. 2:40two things first is the keyboard key
  77. 2:42code and then the second one is the
  78. 2:44GamePad key code so uh if you're playing
  79. 2:46on PC then we need to consider the
  80. 2:48keyboard key code that uh you should
  81. 2:50press in order to activate this
  82. 2:53proximity prompt which by default it's e
  83. 2:55so if we select this then we can select
  84. 2:57uh a bunch of different keys that we can
  85. 2:59use rather than e but just by default
  86. 3:01we're going to set it to e and then the
  87. 3:03second thing is the gam pad key code so
  88. 3:05if you're playing on Xbox or PS4 then
  89. 3:08this is what is going to be replaced for
  90. 3:10the GamePad key code instead next thing
  91. 3:12is the object text and the action text
  92. 3:15both of these are two different things
  93. 3:16and I'm going to help you understand the
  94. 3:18difference between these two so object
  95. 3:20text is basically the part or object
  96. 3:22that the proximity prompt is currently
  97. 3:24in that we're trying to interact with so
  98. 3:27you can think of object text as what is
  99. 3:30it that we're interacting with and then
  100. 3:32we have action text here which is
  101. 3:33basically the action that we're going to
  102. 3:35be taking with this object that we're
  103. 3:37looking at right here which is this
  104. 3:38proximity prompt so it can either be
  105. 3:41like what action are we going to take or
  106. 3:43it could also just be what do you want
  107. 3:44the player to do once you activate this
  108. 3:47part so for the object text what I'm
  109. 3:49going to do is just call this proximity
  110. 3:52part and then for the action text we
  111. 3:54could just say click just like this just
  112. 3:56to make it something different and then
  113. 3:57if we go to test and then hit play then
  114. 3:59what we should see is if we walk up to
  115. 4:02it then it's going to first say the
  116. 4:04object text which is going to be the
  117. 4:06proximity part and then what's in white
  118. 4:09this is going to be the action text
  119. 4:11right here and then on the left side
  120. 4:13it's going to show our key that we have
  121. 4:15to press in order to interact with it
  122. 4:16which is e so now we've customized our
  123. 4:19proximity prompt just a little bit but
  124. 4:20if we try to interact with it it's still
  125. 4:22not going to work because this is
  126. 4:24something we need to script ourselves so
  127. 4:26that is basically some key aspects to
  128. 4:29proximity pars that I wanted to show you
  129. 4:31so what I'm going to do is I'm going to
  130. 4:32go to our proximity part I'm going to
  131. 4:34click on the plus sign and I'm going to
  132. 4:35insert a script so within the script
  133. 4:38what I'm going to do is first locate our
  134. 4:39proximity prompt by saying local
  135. 4:42proximity prompt equals script. parent.
  136. 4:46proximity prompt just like this and
  137. 4:48there's two events for proximity prompts
  138. 4:50that we can use the first one is going
  139. 4:52to be called proximity
  140. 4:55prompt. triggered uh colon connect
  141. 4:59function open close parenthesis enter
  142. 5:01now what this uh event does is it
  143. 5:04basically activates when we interact
  144. 5:07with the proximity prompt by pressing e
  145. 5:09so there's one argument that gets ped
  146. 5:12here which is the player who triggers
  147. 5:14this proximity prompt so I'm just going
  148. 5:16to pass this in as a player and what we
  149. 5:18can do just for a simple example is
  150. 5:20print the player's name just like so
  151. 5:23whenever we interact with the proximity
  152. 5:24prompt so if we go into the game and hit
  153. 5:25play and we walk up to the proximity
  154. 5:27prompt and press e on it then what
  155. 5:29should see in the output is the name of
  156. 5:31the player who interacted with it which
  157. 5:33in this case is me braw battle now
  158. 5:36there's something else we can do with
  159. 5:37this proximity prompt and that is adding
  160. 5:39a hold duration to it uh so that we
  161. 5:42don't just press the key and then it'll
  162. 5:44automatically trigger so that's with the
  163. 5:46use of hold duration down here which is
  164. 5:49in seconds so if I put this for let's
  165. 5:51say 2 seconds then it's going to add a
  166. 5:54hold duration before it actually
  167. 5:56triggers the proximity prompt so now if
  168. 5:58we go into the game and try this out for
  169. 6:00ourselves so we can't press it anymore
  170. 6:03but instead we have to hold it for 2
  171. 6:05seconds before it triggers it once down
  172. 6:08here by printing out braw battle so that
  173. 6:10is a little something I wanted to add
  174. 6:12there just for more functionality
  175. 6:13another thing we can do is add a hold
  176. 6:16down functionality to this proximity
  177. 6:18prompt if that makes sense like you
  178. 6:19basically hold down the proximity prompt
  179. 6:22and then after a certain period of time
  180. 6:23when you let go then it's basically
  181. 6:25going to stop executing the proximity
  182. 6:26prompt and we're going to be doing this
  183. 6:28by using another event called triggered
  184. 6:32ended so if I drop two lines down here
  185. 6:33and say proximity
  186. 6:36prompt. triggered ended just like this
  187. 6:39colon connect function open close
  188. 6:41parenthesis and we're going to pass in
  189. 6:43the player once again and then we're
  190. 6:44going to hit enter so uh what we can do
  191. 6:46is just say player has let go of the
  192. 6:50proximity prompt just like this and if
  193. 6:53we go inside of the game and then hit
  194. 6:55play then what we should see happening
  195. 6:58is if we activate this proximity prompt
  196. 7:01by holding e for two seconds then it's
  197. 7:02going to print out my name I still have
  198. 7:04the E key uh held down on the keyboard
  199. 7:06but once I let go then it's going to say
  200. 7:08player has let go of the proximity
  201. 7:10prompt and now we're able to um use this
  202. 7:12proximity prompt again so that is
  203. 7:14basically how we hold down quote unquote
  204. 7:17a proximity prompt and you might find
  205. 7:19this to be useful if you ever wanted to
  206. 7:21try and do this inside of your own game
  207. 7:23if you're wondering if we can do this
  208. 7:24local sided yes we can and it's pretty
  209. 7:26easy actually so what we're going to do
  210. 7:28is we're going to go to our script and
  211. 7:29we're just going to quickly disable this
  212. 7:31I'm going to go to uh starter player and
  213. 7:34I'm going to insert a local script
  214. 7:35inside of starter player scripts just
  215. 7:37like this it doesn't have to
  216. 7:38specifically be here but just as as an
  217. 7:40example this is where I'm going to put
  218. 7:41the local script and the first thing I'm
  219. 7:43going to do is locate the proximity
  220. 7:45parts so I'm going to say local
  221. 7:48proximity part equals game. workpace
  222. 7:51colon wait for child proximity part and
  223. 7:54then I'm going to locate the proximity
  224. 7:56prompt by saying local proximity prompt
  225. 8:00equals proximity part colon wait for
  226. 8:02child proximity prompt just like that
  227. 8:04and then I'm going to say proximity
  228. 8:06prompt dot triggered colon connect
  229. 8:09function open close parenthesis and then
  230. 8:11we're going to pass in the player
  231. 8:12although you could also just refer to
  232. 8:14the local player since this is a local
  233. 8:17script now but we're just going to pass
  234. 8:18in the player argument here just like so
  235. 8:21and just as a little example what we're
  236. 8:22going to do is I'm going to add a remote
  237. 8:24event inside of replicated storage send
  238. 8:27this over to the server so that the
  239. 8:28player who triggered this proximity
  240. 8:31prompt will get their health be reduced
  241. 8:32by 10 just to like show you a practical
  242. 8:34example so what I'm going to do is hit
  243. 8:36the plus sign I'm going to insert a
  244. 8:38remote event just like this and I'm
  245. 8:40going to say take damage just like that
  246. 8:43and I'm going to locate this inside of
  247. 8:45replicated storage so I'm going to say
  248. 8:47local uh take damage equals game.
  249. 8:51replicated storage colon wait for child
  250. 8:53take damage just like this and then I'm
  251. 8:55going to say take damage fire server
  252. 8:57just like that and now I'm going to
  253. 8:59insert insert a script inside of the
  254. 9:01server script service I'm going to go
  255. 9:02back to the local script and just copy
  256. 9:04our take damage reference and paste it
  257. 9:06in here and then I'm going to say take
  258. 9:08damage. ons server vent connect function
  259. 9:12open close parenthesis player just like
  260. 9:14this and then I'm going to basically
  261. 9:16just say player.
  262. 9:19character. humanoid do Health minus
  263. 9:23equals 10 just like this just as a very
  264. 9:25simple example basically what this is
  265. 9:27going to do is every time we activate
  266. 9:29the proximity prompt on the local side
  267. 9:32then it's basically going to get rid of
  268. 9:3410 HP from our character every single
  269. 9:37time we interact with it so what I'm
  270. 9:39going to do is I'm actually going to get
  271. 9:40rid of the whole duration so I'm going
  272. 9:42to make this zero and I'm going to go
  273. 9:44and hit play so once we interact with
  274. 9:46this proximity pumpt by hitting it once
  275. 9:49and if I go to the client or sorry the
  276. 9:51server then it's going to say that my
  277. 9:54character's Health was reduced by 10 so
  278. 9:57if I press it twice and I go to to the
  279. 9:59server then it's going to keep reducing
  280. 10:01it by 10 every single time so I'm just
  281. 10:03going to like spam this and then as you
  282. 10:05can see I'm like basically almost dead
  283. 10:06just by doing this and if I keep going
  284. 10:08then I'm basically dead so that's like a
  285. 10:10little functionality for local sided
  286. 10:12scripting for proximity prompts if you
  287. 10:14ever found this to be useful not just
  288. 10:16for this health system but for like
  289. 10:18basically anything you could also do
  290. 10:20this in the server side as well so don't
  291. 10:21feel like it's restricted to just local
  292. 10:24side or server side it just depends on
  293. 10:25your preference but there are some
  294. 10:27instances where it will be useful to do
  295. 10:28it on the client side okay so I've seen
  296. 10:30this problem happen a lot with proximity
  297. 10:32prompts where it just doesn't show up
  298. 10:34when you try interacting with it within
  299. 10:36the game and one of the most famous
  300. 10:38examples is if we let's say had a part
  301. 10:41that was too wide like this and we had
  302. 10:45the proximity prompts that was still
  303. 10:46contained within this part so if I were
  304. 10:49to go into the game and hit play and we
  305. 10:50walk up to and try to interact with it
  306. 10:52then it's not going to show up because
  307. 10:54it's located in the center of the part
  308. 10:56that we're trying to interact with
  309. 10:58rather than being anywhere inside of
  310. 11:01this part right here and so this is a
  311. 11:02common problem that people have when it
  312. 11:04comes to using proximity prompts in
  313. 11:06their game they're actually is a
  314. 11:07solution to this by being able to select
  315. 11:10which area of a part that you can have
  316. 11:13this proximity prompt in for more
  317. 11:15accurate interaction with the part that
  318. 11:17you're trying to interact with and that
  319. 11:19is with the use of attachments which I
  320. 11:21actually haven't talked about on my
  321. 11:22channel yet but I'm going to be showing
  322. 11:24you the basics of it in this video so
  323. 11:26that you can use it for your proximity
  324. 11:27prompts so I'm just going to hit stop
  325. 11:29right here an attachment is just simply
  326. 11:31a point that is contained within a part
  327. 11:35so here's what an attachment looks like
  328. 11:37if we were to go to the proximity prompt
  329. 11:38and we hit the plus sign and we inserted
  330. 11:41a attachment it's going to look like
  331. 11:42this so once we insert this attachment
  332. 11:45and select it then we can see this
  333. 11:47little Green Dot right here with two
  334. 11:49axes going on the X Direction and One
  335. 11:51going on the y direction now this is
  336. 11:54basically where we're going to put our
  337. 11:56proximity prompt so that we can have a
  338. 11:57more accurate location
  339. 11:59for where we want the player to interact
  340. 12:01with this proximity prompt so what I'm
  341. 12:02going to do is I'm going to go to home
  342. 12:04and I'm going to select the move tool
  343. 12:06and then I'm going to move the
  344. 12:08attachment this way so that we can have
  345. 12:11it over here and let's say this was a
  346. 12:13door then I would probably have it
  347. 12:14somewhere that's over uh let's say here
  348. 12:18this is basically where we're going to
  349. 12:19have our proximity prompt so now what
  350. 12:21I'm going to do is I'm going to take our
  351. 12:23proximity prompt in the Explorer and I'm
  352. 12:24going to drag it inside of the
  353. 12:26attachment just like this and what I'm
  354. 12:28now going to do is reenable our script
  355. 12:31here that's inside the proximity prompt
  356. 12:33and I'm going to relocate our proximity
  357. 12:36prompt so it's going to be script.
  358. 12:38parent.
  359. 12:39attachment just like this and then it's
  360. 12:42going to be the proximity prompt just
  361. 12:44like so so now if we go uh hit test and
  362. 12:47hit play then what we should see inside
  363. 12:49of the part that the proximity prompt is
  364. 12:51now over here because it is contained in
  365. 12:54the attachment where we specified in
  366. 12:56this part so this is very useful if you
  367. 12:58want to specify a specific location of
  368. 13:01where you want to use this proximity
  369. 13:03prompt rather than just have it be in
  370. 13:05the center of the part that it's
  371. 13:06attached to by default so if we now
  372. 13:09interact with this then it's going to
  373. 13:10print out my name at the bottom when I
  374. 13:12let go of e then it's going to say
  375. 13:13player has let go of the proximity
  376. 13:15prompt and that is basically how we use
  377. 13:17attachments to solve this problem that a
  378. 13:19lot of developers do face with proximity
  379. 13:21prompts so Roblox has another property
  380. 13:23for us to use with proximity prompts and
  381. 13:26that is called exclusivity which
  382. 13:28basically tells tells us like how many
  383. 13:31proximity prompts do we want to show on
  384. 13:33screen if we're close by to them or if
  385. 13:35we want to just show one proximity
  386. 13:37prompts one at a time just so that we
  387. 13:39don't have a bunch of proximity prompts
  388. 13:41shown at the same time within the same
  389. 13:43distance that's what exclusivity does
  390. 13:45for us and I'm going to show you the
  391. 13:46difference between all three settings
  392. 13:48here which the first one by default is
  393. 13:50called one per button but just to make
  394. 13:52things simple I'm actually going to take
  395. 13:54the attachment and what I'm going to do
  396. 13:56is I'm going to duplicate it and then
  397. 13:58move it this way like this and I'm also
  398. 14:00going to duplicate it one more time and
  399. 14:02then move it upward just like this so
  400. 14:03now we have three attachments with three
  401. 14:06proximity prompts in them so I'm just
  402. 14:08going to select all of them and I'm
  403. 14:10going to click on the drop down I'm
  404. 14:11going to first show you always show
  405. 14:14which I think is the most
  406. 14:15self-explanatory one so if we hit play
  407. 14:17then what we should see is basically all
  408. 14:20of the proximity prompts showing at the
  409. 14:23exact same time as long as I'm within
  410. 14:25the range for this proximity prompt
  411. 14:27which we can specify with the max
  412. 14:30activation distance which is 10 studs so
  413. 14:32all of them show at the exact same time
  414. 14:35but there's a way we can change the
  415. 14:36exclusivity of these proximity prompts
  416. 14:38so if we hit stop then I'm going to show
  417. 14:40you the other ones so the next one is
  418. 14:43called one globally which basically only
  419. 14:46shows one proximity prompt at a time if
  420. 14:48we were to go inside of here then it's
  421. 14:50basically only going to show one
  422. 14:52proximity prompt and it's not going to
  423. 14:53show all three of them at the same time
  424. 14:55so that's what one globally means but
  425. 14:57now the last one this one's going to be
  426. 14:59a little tricky this one is called one
  427. 15:01per button which basically means that
  428. 15:04it's going to exclusively show a
  429. 15:07proximity prompt if two proximity
  430. 15:09prompts or more have the same exact key
  431. 15:12that's contained within it so what I'm
  432. 15:14talking about is for all of these all of
  433. 15:17them use the E key to activate it but if
  434. 15:20I had this third attachment let's say
  435. 15:23this one right here if we change the
  436. 15:24keyboard key code to something different
  437. 15:27like let's say r
  438. 15:29and if we now go into the game and hit
  439. 15:31play then what we should see is
  440. 15:33basically a proximity prompt here that
  441. 15:35says we can press e but also it shows
  442. 15:38the r key that we can press as well but
  443. 15:40it's not showing both of the E proximity
  444. 15:43prompts because we said it to be one per
  445. 15:45button I hope like this has made sense
  446. 15:47to you where it's like if we have one
  447. 15:49per button then it's only going to show
  448. 15:50proximity prompts of having one
  449. 15:52proximity prompt per button one of them
  450. 15:55being R and one of them being e but if
  451. 15:57this was let's say one GL globally then
  452. 15:59it doesn't matter what key it is because
  453. 16:01it's still going to show one proximity
  454. 16:03prompt no matter what so that's
  455. 16:05basically how exclusivity works and I
  456. 16:07hope that you found this part to be
  457. 16:08useful so for this last part of the
  458. 16:10video I want to quickly address the
  459. 16:11difference between a proximity prompt
  460. 16:13and a click detector now a click
  461. 16:16detector is basically roblox's old way
  462. 16:18of being able to interact with objects
  463. 16:21inside of the game so if I were to show
  464. 16:24you what this looks like let's insert a
  465. 16:26click detector inside of the proximity
  466. 16:28prompt and let's hit play so if I were
  467. 16:31to hit play then what we should see is
  468. 16:33this icon change inside of our Mouse
  469. 16:36where it shows that we are able to click
  470. 16:38on this part now this is the only
  471. 16:40functionality that this click detector
  472. 16:42does it allows us to click this object
  473. 16:45that's contained within the game and
  474. 16:46that's basically all this does so it's
  475. 16:48pretty simple and it's pretty primitive
  476. 16:50compared to what we have now with
  477. 16:52proximity prompts so you can use click
  478. 16:54detectors in your game if you want but
  479. 16:56proximity prompts kind of supersede the
  480. 16:59functionality of Click detectors and you
  481. 17:00don't need click detectors anymore but
  482. 17:02there can be some use cases of when you
  483. 17:04would decide to use click detectors over
  484. 17:06proximity prompts so that is kind of a
  485. 17:09little explanation that I can give with
  486. 17:11click detectors now if you want to make
  487. 17:12this click detector functional I can
  488. 17:14quickly add a script and I'm going to uh
  489. 17:17say script. parent and there's only one
  490. 17:20event that's useful which is mouse click
  491. 17:23colon connect function open close
  492. 17:26parenthesis and then we pass in the
  493. 17:28player clicked on it just like we did
  494. 17:30with proximity prompts and then we can
  495. 17:31print out player clicked on the part and
  496. 17:34then if we were to go into the game and
  497. 17:36hit play then what we should see is if
  498. 17:38we click on the part then it's going to
  499. 17:40say player clicked on the part and that
  500. 17:41is pretty self-explanatory one last
  501. 17:43thing is the max activation distance
  502. 17:45kind of like proximity prompts where
  503. 17:46it's like how far away does it take for
  504. 17:48us to actually click on this part or
  505. 17:50interact with it and things like that
  506. 17:52and so that is basically the difference
  507. 17:54between proximity prompts and click
  508. 17:55detectors and it's kind of a matter of
  509. 17:57preference of which one you decide to to
  510. 17:58use for your Roblox game so that is
  511. 18:01basically going to be it for this
  512. 18:02episode and I hope you enjoyed this
  513. 18:03tutorial on proximity prompts so if you
  514. 18:06want to learn more about interacting
  515. 18:07with parts in the game using guis then I
  516. 18:10encourage you to watch my billboard GUI
  517. 18:13tutorial that I will have for you right
  518. 18:14here on screen but with that being said
  519. 18:16that's basically going to be it for this
  520. 18:17episode I hope you enjoyed it and I will
  521. 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.