YouTube2Text

Subscriptions - Roblox Advanced Scripting #30 — Transcript

by BrawlDev · 5,571 words · 757 segments · language en · Watch on YouTube

Full transcript

  1. 0:00Newbert can you actually just get out of
  2. 0:02my way so that I can play the game like
  3. 0:04I'm supposed to like I can't do that
  4. 0:06while you're here standing in front of
  5. 0:08me okay what do you even want Newbert
  6. 0:11wait your journey will be tough you
  7. 0:13should take me with you um what do you
  8. 0:16mean by that Newbert oh wait a minute
  9. 0:19what is this Newbert companion $299 per
  10. 0:23month let nubert join you on your
  11. 0:25journey uh I didn't know you were some
  12. 0:27crazy salesperson nubert I am not taking
  13. 0:29your off okay how does that make you
  14. 0:31feel oh my God no stop showing me the
  15. 0:34subscription I do not want to be I don't
  16. 0:36I do not want you as my companion okay
  17. 0:38stop showing me this okay well it looks
  18. 0:40like Newbert isn't going to move unless
  19. 0:42I buy his subscription so fine Newbert I
  20. 0:44will pay for your companion subscription
  21. 0:47let's just click this and oh he's gone
  22. 0:50oh wait why am I moving so weird wait
  23. 0:52wait what the heck Newbert what are you
  24. 0:57doing bro wait is this what you mean by
  25. 1:00companion just being attached to my back
  26. 1:02like this bro this is more of an
  27. 1:03inconvenience why did I even buy that oh
  28. 1:06my goodness okay I'm just going to reset
  29. 1:08my character I do not want you to be on
  30. 1:10my back throughout this entire Journey
  31. 1:12wait no no he's stuck with me bro damn
  32. 1:18it I I paid $2.99 for this really I paid
  33. 1:22I paid three bucks for this really oh
  34. 1:25this is going to go on until my
  35. 1:26subscription period ends oh this sucks
  36. 1:28you know what I'm not playing this game
  37. 1:29anymore more okay well Newbert you can
  38. 1:31take my money I don't care anymore all
  39. 1:34right let's think about this for a
  40. 1:35minute this video is going to be about
  41. 1:37subscriptions which allows developers to
  42. 1:40earn Ro Robux through monthly purchases
  43. 1:43inside of their own game so in the past
  44. 1:46we've worked with other methods of
  45. 1:47earning Roo one of them being game
  46. 1:50passes and the other one being developer
  47. 1:51products now to summarize the difference
  48. 1:53between them a Game Pass is a one-time
  49. 1:55purchase but a Dev product is a product
  50. 1:58that you can buy as many times as you'd
  51. 2:00like whenever you'd like so now in this
  52. 2:03episode I'm going to be teaching you
  53. 2:04about subscriptions which is another
  54. 2:06method of earning Robux and to basically
  55. 2:08demonstrate how a subscription works I
  56. 2:10have this VIP door right here so I want
  57. 2:12you to imagine that there's a VIP lounge
  58. 2:14through this door that you can't access
  59. 2:16because you did not buy the VIP door
  60. 2:18subscription so if I were to prompt this
  61. 2:21VIP door subscription it's going to look
  62. 2:23something like this so it's going to
  63. 2:24give you a price for every month that
  64. 2:28you have to pay in order to keep this
  65. 2:30subscription so in this case it's $2.99
  66. 2:32a month so once I buy this subscription
  67. 2:35then it's going to unlock the VIP door
  68. 2:38so I can go inside the VIP lounge and
  69. 2:40this is going to go on for every single
  70. 2:42month as long as I keep paying uh how
  71. 2:45much the price is every single month but
  72. 2:47if I decide to cancel my subscription
  73. 2:49and the subscription period ends then
  74. 2:52it's going to lock the VIP door again
  75. 2:55because our subscription period ended
  76. 2:56and we're not paying for the
  77. 2:58subscription anymore so this is what
  78. 2:59what makes a subscription different from
  79. 3:02a game pass and a developer product and
  80. 3:04so I'm going to be teaching you how to
  81. 3:05implement this inside of Roblox studio
  82. 3:08so with that being said let's now go
  83. 3:10ahead and go straight into implementing
  84. 3:12now that we understand it let's
  85. 3:13Implement subscriptions inside Roblox
  86. 3:15Studio but before we can add
  87. 3:17subscriptions in our game we need to
  88. 3:18make sure that our game is published so
  89. 3:21I want you to go to file and then hit
  90. 3:23publish to Roblox and once you've done
  91. 3:25that then I'm going to meet you at the
  92. 3:26Roblox Creator Hub so I'll see you there
  93. 3:28in just a little bit all right so I'm
  94. 3:29here in the Roblox Creator Hub and we're
  95. 3:31going to go to the game that we just
  96. 3:32published which in this case this is the
  97. 3:34game that I'm using right now so if we
  98. 3:36click on this then there should be a tab
  99. 3:38on the left side called subscriptions
  100. 3:40under the monetization tab so if we go
  101. 3:42over here then it should show all the
  102. 3:44subscriptions that we have inside of the
  103. 3:47game just ignore these three down here
  104. 3:49but in order to create a subscription we
  105. 3:50need to press this button that says
  106. 3:52create a subscription right here and it
  107. 3:54should show a bunch of information that
  108. 3:56we need to give before we can start
  109. 3:58adding one like uploading an image in
  110. 4:00this case so I'm just going to pick some
  111. 4:02random image doesn't really matter too
  112. 4:03much um and let's say for our first
  113. 4:06subscription let's try and recreate that
  114. 4:08VIP door from the start of this episode
  115. 4:10so I'm just going to call this VIP
  116. 4:13lounge just like this and there's going
  117. 4:15to be a subscription period which is
  118. 4:16locked to monthly and that's because
  119. 4:19this is the only subscription period
  120. 4:20option we have right now so whenever a
  121. 4:23user buys the subscription then it's
  122. 4:24going to charge them every single month
  123. 4:26after that as long as they have their
  124. 4:28subscription active next thing we have
  125. 4:30is price so the prices I believe are
  126. 4:33local to wherever you currently live
  127. 4:35right now but for me it's USD so the
  128. 4:37base price is $2.99 and then it can go
  129. 4:40all the way up to $14.99 so in this case
  130. 4:42let's say we choose $2.99 then it's
  131. 4:45going to show on the right side that the
  132. 4:47subscriber has to pay
  133. 4:48$2.99 but then the developer earns Roo
  134. 4:51in return and that's actually important
  135. 4:53to note here is that the developer earns
  136. 4:56Roo if the user buys your subscription
  137. 4:59with real currency let's also add a
  138. 5:01description by saying this gives you
  139. 5:04access to the VIP lounge and then
  140. 5:08finally we have product type here so
  141. 5:09there's three options to put here and to
  142. 5:11be honest it doesn't really matter what
  143. 5:13you put here because I haven't found any
  144. 5:15use to determine the product type inside
  145. 5:17of your scripts at least from what I've
  146. 5:19experimented so to explain what Dural is
  147. 5:21it's basically a permanent benefit that
  148. 5:23you get inside of your game as long as
  149. 5:25your subscription is still active so the
  150. 5:27VIP DF in in this case is a durable uh
  151. 5:30subscription so next thing we have is
  152. 5:32consumable which is temporary or limited
  153. 5:34which is basically like a potion or like
  154. 5:37a piece of food where it's like a player
  155. 5:38is given this product but then once they
  156. 5:40use it they can't like use it anymore if
  157. 5:42that makes sense and then currency now
  158. 5:44currency I believe you just get currency
  159. 5:47at the start of your subscription and
  160. 5:48then you get it every single month
  161. 5:50afterwards as like a fixed amount like
  162. 5:52let's say you get 1,000 coins at the
  163. 5:53start of every single subscription
  164. 5:55period that's basically what this is so
  165. 5:57let's do durable as our VIP Lounge uh
  166. 6:00subscription and then we're going to hit
  167. 6:01create subscription so once we do this
  168. 6:04then we should have the subscription be
  169. 6:07created inside of our subscriptions tab
  170. 6:09just like this okay so our VIP lounge
  171. 6:11subscription should be right here now
  172. 6:13there's two important things we need to
  173. 6:14do first thing is we need to make sure
  174. 6:17that our subscription is active before
  175. 6:19we can start purchasing it so what I'm
  176. 6:21going to do is hit the three dots right
  177. 6:23here and I'm going to hit active just
  178. 6:24like this so then I'm going to hit
  179. 6:27active again just like so and now we
  180. 6:29have our subscription that's active now
  181. 6:31if this is your first subscription
  182. 6:33you're creating it's going to ask you to
  183. 6:34write a shortened version of your Roblox
  184. 6:36place that's going to be displayed for
  185. 6:39every subscription that you buy which in
  186. 6:41this case for me I named it brawls
  187. 6:42tutorial place so that's what's going to
  188. 6:44show if I do buy the subscription okay
  189. 6:47and finally the last thing is our ID
  190. 6:49which is right here so I'm going to uh
  191. 6:50click this copy button because this is
  192. 6:52going to be important for later so now
  193. 6:54that we have our first subscription
  194. 6:55let's go back to Roblox Studios so we
  195. 6:57can start implementing this now I want
  196. 6:59to make a very quick disclaimer that you
  197. 7:01might see this where it says you can't
  198. 7:03create subscriptions and that's because
  199. 7:05you need to be ID or phone verified to
  200. 7:08create subscriptions for your game so my
  201. 7:10recommendation is to go to your Roblox
  202. 7:12account settings and add a phone number
  203. 7:15so that you can be phone verified since
  204. 7:16in my opinion that's the easier criteria
  205. 7:19to check off before you can start
  206. 7:21creating subscriptions so I just wanted
  207. 7:22to address that first before we
  208. 7:24continued on with creating subscriptions
  209. 7:26all right so we're back inside studio
  210. 7:27and the first thing we need to be able
  211. 7:28to do is prompt the subscription to the
  212. 7:31player so that when they buy the
  213. 7:32subscription it'll tell the server that
  214. 7:34we want to give the benefits to the
  215. 7:36player once they actually do buy the
  216. 7:38subscription but that's going to be
  217. 7:40later in this episode for right now all
  218. 7:41we need to do is prompt the user the
  219. 7:44subscription so we can do that through a
  220. 7:46local script somewhere in the Explorer
  221. 7:48let's say starter GUI so I'm going to
  222. 7:51insert a local script like this and
  223. 7:52first thing we're going to do is make
  224. 7:54reference to Marketplace service which
  225. 7:56is what we used inside of our game
  226. 7:58passes and Dev products episodes so
  227. 8:00we're going to say local Marketplace
  228. 8:03service equals gameon get service open
  229. 8:06and close parentheses Marketplace
  230. 8:09service just like that and then we're
  231. 8:11also going to locate our local player by
  232. 8:13saying local player equals game.
  233. 8:16players. local player just like that and
  234. 8:20then finally we're going to add in our
  235. 8:22subscription ID as a variable by saying
  236. 8:24local sub ID equals and then we're going
  237. 8:27to paste in our ID that we copied which
  238. 8:29looks like this now what's interesting
  239. 8:31about this subscription ID is we
  240. 8:32actually need to wrap it around in
  241. 8:34quotations so that it's a string rather
  242. 8:37than a number because it has this little
  243. 8:38XP Dash right before the the number so
  244. 8:42now that we have all the information we
  245. 8:44need let's make it so that if we wait
  246. 8:46about 5 seconds then it's going to
  247. 8:48prompt the user the subscription to buy
  248. 8:50so we're going to add a task. wait for
  249. 8:52about 5 seconds and then we're going to
  250. 8:54say Marketplace service colon
  251. 8:57prompt subscription purchase just like
  252. 9:00this and we're going to pass in the
  253. 9:02player object and then we're also going
  254. 9:03to pass in the subscription ID just like
  255. 9:05this so This Is How We prompt the user
  256. 9:08to buy the subscription so if you go to
  257. 9:10the game hit test and hit play then what
  258. 9:12we should see in about 5 seconds is that
  259. 9:15the game is going to prompt us the
  260. 9:17subscription that we just created so as
  261. 9:19you can see right here we have our
  262. 9:20subscription over here that says VIP
  263. 9:22lounge and we're going to buy this for
  264. 9:24$2.99 every single month after we
  265. 9:26subscribe to it so if we click on this
  266. 9:28then that should give us all the
  267. 9:29benefits but we obviously need to
  268. 9:31implement that ourselves first but this
  269. 9:33is how we prompt the user to buy the
  270. 9:36subscription okay now let's give
  271. 9:38benefits to the player once they
  272. 9:39actually do buy the subscription inside
  273. 9:41the game and the way we're going to do
  274. 9:43that is we're going to insert a script
  275. 9:44inside of server script service just
  276. 9:46like this and I'm going to rename this
  277. 9:48to
  278. 9:50subscription Handler just like this
  279. 9:52we're also going to delete this uh line
  280. 9:53of code right here so what we're going
  281. 9:55to do is go back to our previous script
  282. 9:57with the local script and we're going to
  283. 9:59select the first three references and
  284. 10:01we're going to paste it inside of here
  285. 10:03but instead of referencing the local
  286. 10:04players since this is a script we're
  287. 10:06actually just going to reference the
  288. 10:08players service by saying local players
  289. 10:11equals game col get service players just
  290. 10:14like this so next thing we're going to
  291. 10:15do is we're going to write a function
  292. 10:18that basically checks the subscription
  293. 10:20status of the player with our
  294. 10:23subscription ID to make sure the player
  295. 10:25does have the subscription and it's
  296. 10:26currently active and we're going to use
  297. 10:28this function for when when the player
  298. 10:29joins the game but also if they decide
  299. 10:32to change their subscription by buying
  300. 10:34the subscription in the game I think
  301. 10:36it'll make more sense once I actually
  302. 10:37show you what the code looks like but
  303. 10:40first we're going to start with our
  304. 10:41function so we're going to say local
  305. 10:43function check substatus open close
  306. 10:47parentheses and we're going to pass in
  307. 10:48two parameters here the first one is
  308. 10:50going to be the player and then the
  309. 10:52second one is going to be the
  310. 10:54subscription ID I'm going to say
  311. 10:56subscription ID so that it's not
  312. 10:57confused with our sub ID up here and
  313. 11:00then we're going to hit enter just like
  314. 11:01this so first thing we're going to do is
  315. 11:04use a function that Marketplace service
  316. 11:06has that allows us to get information
  317. 11:09about the subscription status so what
  318. 11:11we're going to do is actually wrap this
  319. 11:12in a PE call because it could fail so
  320. 11:14we're going to say local success comma
  321. 11:18res response equals P call function open
  322. 11:22close parentheses enter and then we're
  323. 11:23going to return Marketplace service
  324. 11:26colon get subscription
  325. 11:29status async open close parentheses and
  326. 11:33we're going to first pass in the player
  327. 11:35and then we're going to pass in the
  328. 11:38subscription ID uh not to confuse it
  329. 11:40with the sub ID up here so now let's
  330. 11:42just make sure this doesn't fail so what
  331. 11:44we're going to do is say if not success
  332. 11:46then we're going to make a warning by
  333. 11:49saying the sub status check wasn't
  334. 11:53successful just to leave like a little
  335. 11:55warning message for us uh in case this
  336. 11:57actually doesn't work so next thing
  337. 11:58we're going to do
  338. 11:59is basically check our response to see
  339. 12:02whether this new subscription status
  340. 12:05change was the player getting the
  341. 12:07subscription or if their subscription
  342. 12:10was removed so the way we're going to do
  343. 12:11that is by saying if response so the
  344. 12:14variable we just fetched back up here
  345. 12:15with get subscriptions as async if
  346. 12:17response. is subscribed then here we're
  347. 12:22going to Grant the benefits but if this
  348. 12:26is not the case then we're going to
  349. 12:27revoke the benefits because they no
  350. 12:29longer have the subscription and so this
  351. 12:31is our basic check substatus function
  352. 12:33that we're going to use for two things
  353. 12:35so if we drop two lines down here we're
  354. 12:37going to say players. player added colon
  355. 12:41connect and then what we're going to do
  356. 12:43is create a function here just really
  357. 12:45quickly a player added function so we're
  358. 12:47going to say local function player added
  359. 12:50open close parentheses and we going to
  360. 12:52pass in the player just like this and
  361. 12:54I'm going to pass that in here for the
  362. 12:56player added uh event so whenever we use
  363. 12:59player added we're just simply going to
  364. 13:01call the check sub status function like
  365. 13:04this by first passing in the player and
  366. 13:05then the subscription ID which is just
  367. 13:07going to be sub ID that we specified up
  368. 13:10here at the start of the script so
  369. 13:12that's the first thing we're going to
  370. 13:13use for check sub status and then the
  371. 13:15second way we're going to use check sub
  372. 13:16status is if the user has changed their
  373. 13:20subscription status through an event and
  374. 13:22we're going to detect that by first
  375. 13:23creating a function and then using the
  376. 13:25event to then call that function so
  377. 13:28basically what we're going to do here is
  378. 13:30create a function before player added or
  379. 13:33after it doesn't really matter what
  380. 13:34we're going to do is say local function
  381. 13:36on user sub change just like this and
  382. 13:41then we're going to first pass in the
  383. 13:43player and then the subscription ID just
  384. 13:46like this and then we're basically going
  385. 13:48to check if the subscription that was
  386. 13:50changed aligns with our subscription up
  387. 13:53here because a user can have many
  388. 13:55subscriptions across multiple Roblox
  389. 13:57games and we need to make sure that this
  390. 13:59is the right subscription ID that has
  391. 14:02been changed that reflects this one up
  392. 14:03here so what we're going to do is say if
  393. 14:06subscription ID equals sub ID then we're
  394. 14:10going to say check sub status we're
  395. 14:14going to pass in the player and then the
  396. 14:16subscription ID just like that and so we
  397. 14:20are now going to go down here and say
  398. 14:24players. user subscription status
  399. 14:27changed colon connect and then we're
  400. 14:30going to pass in the on user sub changed
  401. 14:33function just like this where it's
  402. 14:35automatically going to pass in the
  403. 14:36player and the subscription ID with
  404. 14:38these two parameters up here so I'm
  405. 14:39hoping so far this is making sense to
  406. 14:41you where we start with player added and
  407. 14:43it's going to check the subscription
  408. 14:45status as soon as they join into the
  409. 14:46game using the VIP door and then it's
  410. 14:48going to be the user subscription status
  411. 14:50change event that's basically going to
  412. 14:52detect when the player actually buys the
  413. 14:55subscription in the game and then it's
  414. 14:58going to pass through through up here by
  415. 14:59doing a validation check to make sure
  416. 15:01that this is the right subscription ID
  417. 15:03and then we're going to call check
  418. 15:05substatus with the subscription ID and
  419. 15:07so this is basically how we have the
  420. 15:11subscription Handler setup going on here
  421. 15:13but now let's actually make the VIP door
  422. 15:16uh with the benefits over here so I'm
  423. 15:18just going to go to the game and we're
  424. 15:20going to make a VIP door really quickly
  425. 15:22so I'm going to go to model and then
  426. 15:23insert a part right here and I'm just
  427. 15:26going to drag this part around scale it
  428. 15:28up just like this this I'm going to call
  429. 15:30this VIP door just like this and let's
  430. 15:33make this like a a very attractive color
  431. 15:35like hot pink and I think this is
  432. 15:37basically all we need for this VIP door
  433. 15:39let's make sure it's anchored and now we
  434. 15:41basically have our VIP door that's right
  435. 15:43over here so what we're going to do is
  436. 15:44go to the script and I'm going to make
  437. 15:46reference to the VIP door by saying
  438. 15:48local VIP door equals game. workpace
  439. 15:52colon wait for child VIP door just like
  440. 15:55this and now what we can do is let's say
  441. 15:58this VIP door is here if the player has
  442. 16:00not bought the subscription so in that
  443. 16:02case if we were to revoke the benefits
  444. 16:04then we're going to say VIP door.
  445. 16:06transparency equals zero and we're also
  446. 16:09going to say VIP door. can Collide is
  447. 16:12set equal to true because this is going
  448. 16:14to make the VIP door visible and the
  449. 16:17player without the subscription will not
  450. 16:19be able to go through but if the
  451. 16:21benefits are granted then we're going to
  452. 16:23make the transparency of the VIP door to
  453. 16:25be one and the can Collide of the VIP
  454. 16:28door is going to be set equal to false
  455. 16:30just like this so that it actually does
  456. 16:32open up if the subscription is bought
  457. 16:35okay so if we now go to test and hit
  458. 16:37pipe then what we should see is after
  459. 16:39about 5 seconds then we should basically
  460. 16:43wait for the subscription thing to show
  461. 16:45up right over here and then we're going
  462. 16:46to say
  463. 16:48subscribe okay something seemed to have
  464. 16:50been wrong here oh okay I see what the
  465. 16:52problem was there was a typo so instead
  466. 16:54of get subscription status async it's
  467. 16:56actually get user subscription status
  468. 16:59asnc that was a very small typo my
  469. 17:00apologies on that and one more thing I
  470. 17:02added was a return statement after we
  471. 17:04make the warning message because there's
  472. 17:06no point to check the rest of the script
  473. 17:08if the PE call was not successful so
  474. 17:09that that was another thing I added to
  475. 17:11it so now if we go into the game and hit
  476. 17:12play what we should see in about 5
  477. 17:15seconds is the subscription that's about
  478. 17:17to show up on our screen so the VIP
  479. 17:20lounge is shown right here for $2.99 a
  480. 17:22month so if we buy it then it's actually
  481. 17:24going to remove the VIP door so we can
  482. 17:26now access the VIP lounge but in the
  483. 17:28event of when our subscription expires
  484. 17:31then this VIP door is going to update in
  485. 17:34real time and it's actually going to
  486. 17:36show the door again because our
  487. 17:38subscription has been deactivated so
  488. 17:41that is basically how we make a
  489. 17:43subscription inside of Roblox studio and
  490. 17:45I hope you found this part to be very
  491. 17:46informative so great we have our first
  492. 17:49working subscription that is this VIP
  493. 17:51door right over here but unfortunately
  494. 17:54that's not the entire picture and it
  495. 17:56actually doesn't work like intended and
  496. 17:58I'll I'll show you why so what I'm going
  497. 18:00to do is go to test and I'm going to run
  498. 18:03a local server with two players so I'm
  499. 18:05going to show you like why this VIP door
  500. 18:07doesn't work as expected okay so I
  501. 18:09loaded up a local server inside of the
  502. 18:11game to have two players playing at the
  503. 18:13same time so for the second player I'm
  504. 18:15actually going to ex out of this
  505. 18:17subscription prompts right over here
  506. 18:18just to show you what happens if the
  507. 18:20first player buys the VIP lounge
  508. 18:22subscription so if I buy this then it's
  509. 18:24actually going to make the door
  510. 18:26disappear for both players that are the
  511. 18:28game and obviously we don't want that we
  512. 18:30want the door to disappear only for the
  513. 18:33player who bought the subscription so we
  514. 18:35need to make sure that we have that
  515. 18:36taken care of and I'm going to show you
  516. 18:37how to fix that okay so back to our
  517. 18:39script obviously we need to be able to
  518. 18:41do this through the local side but how
  519. 18:44do we do this through the local side
  520. 18:46well one thing we can do for sure is we
  521. 18:48can create a remote function that
  522. 18:52basically fetches information about
  523. 18:54whether the player actually is
  524. 18:55subscribed or not and we can use that
  525. 18:57information to basically determine if
  526. 19:00the player's VIP door should be open or
  527. 19:02it shouldn't be open based on the new
  528. 19:05change that has happened to it so here's
  529. 19:06what we're going to do in replicated
  530. 19:08storage we're going to insert a remote
  531. 19:10function and we're going to call this
  532. 19:12remote function get user sub status just
  533. 19:16like this and then inside of our
  534. 19:18subscription Handler what we're going to
  535. 19:20do is first make reference to our remote
  536. 19:23function that we just created so we're
  537. 19:24going to say local get user sub status
  538. 19:28stat equals game. replicated storage
  539. 19:32colon wait for child get user substatus
  540. 19:35just like this and what we're going to
  541. 19:36do is basically create a ons server
  542. 19:38invoke function probably somewhere down
  543. 19:40here so we're going to say get usersub
  544. 19:42status. ons server invoke equals
  545. 19:45function open close parenthesis and by
  546. 19:48default the first parameter is going to
  547. 19:49be the player that gets passed through
  548. 19:52so what we're going to do here is
  549. 19:54basically take our code that we had up
  550. 19:56here with the get subscription status
  551. 19:58async and we're just going to copy this
  552. 20:00and paste it down here so for this user
  553. 20:03sub status another thing we're going to
  554. 20:04do is actually pass in the subscription
  555. 20:07ID as well and also replace this player
  556. 20:09variable with plr because that's what we
  557. 20:11specified it as so now that we have
  558. 20:13response what we're basically going to
  559. 20:15do is first check if this was not
  560. 20:18successful so I'm just going to go up
  561. 20:19here and copy the code that we had over
  562. 20:21here so the sub status check wasn't
  563. 20:23successful for the client just to make
  564. 20:26this a little different that's what
  565. 20:27we're going to do and then we're going
  566. 20:29to return
  567. 20:31response. is subscribed back to the
  568. 20:34client when we invoke this get user
  569. 20:38substatus remote function so what we're
  570. 20:40first going to do is go up here and take
  571. 20:42this reference with get user substatus
  572. 20:44and we're going to go to our local
  573. 20:45script and we're going to make that
  574. 20:48reference up here with get user sub
  575. 20:50status and then we're going to drop two
  576. 20:52lines down here so now we're going to do
  577. 20:54everything before the task. we so that
  578. 20:56there isn't a delay for whenever we're
  579. 20:58detecting these things with the
  580. 21:00subscriptions so I'm just going to make
  581. 21:02a little bit of space up here and the
  582. 21:04first thing we're going to do is make a
  583. 21:06function that basically hides the door
  584. 21:09on the local side if the player does
  585. 21:11have the subscription or if they don't
  586. 21:13have the subscription active so what
  587. 21:14we're going to do is say local function
  588. 21:17hide door if player has sub open close
  589. 21:21parentheses and then I'm just going to
  590. 21:23hit enter just like this so what we're
  591. 21:25also going to do is go up here to our
  592. 21:27script I'm going to take the VIP door
  593. 21:29reference and put it inside of our local
  594. 21:31script over here and so now what we're
  595. 21:32going to do inside of this function is
  596. 21:34basically check if the player does have
  597. 21:36the VIP door subscription active through
  598. 21:39this remote function that we just
  599. 21:40created so what we're going to do is say
  600. 21:42local player has sub equals get user sub
  601. 21:47status colon in invoke server just like
  602. 21:53this and then we're going to hit enter
  603. 21:54now we also need to specify the
  604. 21:55subscription ID by passing in sub ID
  605. 21:58just like this and it's going to
  606. 22:00automatically pass in the player as the
  607. 22:02first argument for the sub status remote
  608. 22:05function so then what we're going to do
  609. 22:06is say if player has sub then we're
  610. 22:09going to rant the
  611. 22:12benefits like we need to and if the
  612. 22:14player doesn't have the subscription
  613. 22:15then we're going to revoke the benefits
  614. 22:18like we did down here as well so we're
  615. 22:19basically just going to copy what we had
  616. 22:22up here with VIP door if they are
  617. 22:25subscribed and we're going to grant them
  618. 22:26the benefits and if they don't then
  619. 22:29we're going to keep the door as is so
  620. 22:31that the player cannot go through the
  621. 22:33VIP door and that is basically how we do
  622. 22:34it so first thing we're going to do is
  623. 22:37check if the player already has the
  624. 22:39subscription as soon as they join into
  625. 22:41the game so I'm just going to make a
  626. 22:43reference to this right over here and
  627. 22:44we're also going to add a event that
  628. 22:48triggers when the user does change their
  629. 22:50subscription like we did inside the sub
  630. 22:53subscription Handler so this is the
  631. 22:54event we're going to use after the
  632. 22:56player has bought a subscription so this
  633. 22:59is going to take place in Marketplace
  634. 23:00service that we have reference to right
  635. 23:02up here by saying Marketplace
  636. 23:05service. prompt
  637. 23:08subscription purchase finished colon
  638. 23:12connect open close parenthesis and we're
  639. 23:14going to pass in the hide door if player
  640. 23:17has sub function that we had up here for
  641. 23:20this hide door function so this is
  642. 23:22basically the entire scripts that we
  643. 23:23need for the subscription now what I can
  644. 23:26tell you about the subscription Handler
  645. 23:27is that we can actually comment out a
  646. 23:29lot of things from this script that we
  647. 23:31created previously so the first thing is
  648. 23:33the sub ID then it's the VIP door and
  649. 23:35then it's the entire check substatus
  650. 23:38function and also the on user sub
  651. 23:40changed and the player added function as
  652. 23:42well so the only thing we really need is
  653. 23:45this on server invoke that tells us if
  654. 23:47the player has this subscription or not
  655. 23:49and it's going to return the result of
  656. 23:51whether the player does have the
  657. 23:53subscription and if it if they do then
  658. 23:56we can grant the benefits or revoke the
  659. 23:58benefits f as we see fit for our local
  660. 24:00script so if we now go into the game and
  661. 24:02hit play then what we should see is that
  662. 24:05in about 5 Seconds when we're prompted
  663. 24:07to buy the VIP door and if we do buy it
  664. 24:10just like we see right over here if we
  665. 24:12click subscribe then it's going to get
  666. 24:14rid of the door but if I go to the
  667. 24:16server then the door is still over here
  668. 24:18because it was not changed for the
  669. 24:21server side and so that is basically how
  670. 24:25we make this fix for this subscription
  671. 24:28that we created for the VIP door so that
  672. 24:30it doesn't affect every single player
  673. 24:32that's within the game and I hope that
  674. 24:33this has made sense to you with how
  675. 24:36we've structured this entire script so
  676. 24:38just to recap one more time I'm going to
  677. 24:40hit stop and if we go through our script
  678. 24:43here so in 5 seconds the script is going
  679. 24:45to prompt the user to buy the
  680. 24:47subscription so that's great now once
  681. 24:49the user has bought the subscription so
  682. 24:51it's going to prompt the subscription
  683. 24:53purchase finished and it's going to pass
  684. 24:55in this function hi door if player has
  685. 24:58sub and it's also going to do it at the
  686. 24:59very start as well just to make sure
  687. 25:01that the player actually does have the
  688. 25:03subscription when they join into the
  689. 25:05game so it's going to invoke this remote
  690. 25:08function to get the subscription status
  691. 25:11of this subscription ID for the VIP door
  692. 25:13so if you go inside of the script then
  693. 25:16it's going to get the user subscription
  694. 25:18status async and it's going to return
  695. 25:21whether the user actually is subscribed
  696. 25:24to this subscription and so once we get
  697. 25:27that result it's going to return true or
  698. 25:30false so since the player does have the
  699. 25:32subscription we're going to Grant the
  700. 25:34benefits by hiding the door but if they
  701. 25:37don't then we're going to keep the door
  702. 25:39open because of it and so that is
  703. 25:42basically how we make our VIP door
  704. 25:45script inside of this episode and I hope
  705. 25:47you found this to be extremely extremely
  706. 25:49useful so if I were to just quickly make
  707. 25:51this Handler script even more simple I
  708. 25:53could just get rid of all of these
  709. 25:54comments that I have over here inside of
  710. 25:57our script and I guess we also don't
  711. 26:00need the players reference anymore as
  712. 26:01well so this is the only thing that
  713. 26:03matters if you understand remote
  714. 26:05functions this is basically all we need
  715. 26:06from the server side but the local side
  716. 26:09is basically going to handle the rest in
  717. 26:11this case because the VIP door needs to
  718. 26:13be local to that specific player and so
  719. 26:16I hope that this has kind of helped you
  720. 26:18understand how subscriptions work on the
  721. 26:21local side but also in the service side
  722. 26:22too that's not to say that everything
  723. 26:24we've coded in the subscription Handler
  724. 26:27has been for nothing because it's
  725. 26:29basically just a matter of knowing
  726. 26:30whether you want to have your scripts be
  727. 26:32on the local side or if you want your
  728. 26:33scripts to be on the server side and so
  729. 26:35I think what we've coded up until this
  730. 26:36point has been pretty helpful in being
  731. 26:39able to understand that as well and so
  732. 26:41that is just something I wanted to
  733. 26:42quickly address before we end off this
  734. 26:44video and so I hope you're able to
  735. 26:46understand everything we've done up up
  736. 26:47until this point and you found this
  737. 26:49episode to be extremely helpful so
  738. 26:50that's pretty much going to be it for
  739. 26:51this episode on subscriptions now before
  740. 26:53you go I want to quickly give a shout
  741. 26:55out to my very first patreon member
  742. 26:58peanut boy 173 so if you like the work
  743. 27:01that I put out on my YouTube channel and
  744. 27:03you want to directly support me while
  745. 27:05also getting access to all of my scripts
  746. 27:07that I've been creating throughout the
  747. 27:09entirety of this Advanced scripting
  748. 27:11tutorial guide then I will leave a link
  749. 27:13to my patreon page in the description of
  750. 27:14this video you don't have to become a
  751. 27:16patreon member to support me but that
  752. 27:19would definitely help me out a lot and I
  753. 27:21would appreciate it very much so that's
  754. 27:24basically all I wanted to say for the
  755. 27:25end of this episode so with that being
  756. 27:27said I hope you enjoyed this video and I
  757. 27:28will see you in the next one take care

About this transcript

This page contains the full transcript of Subscriptions - Roblox Advanced Scripting #30 by BrawlDev, generated from the public captions YouTube serves with the video. The transcript has 5,571 words across 757 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.