Adding Twitter Codes! Roblox Studio Simulator Guide Episode 30 — Transcript
Full transcript
- 0:00welcome back to the simulator Series in
- 0:01today's episode we are going to be
- 0:02adding in codes to our game which
- 0:04players can redeem for some rewards as
- 0:06always if you guys do enjoy the video or
- 0:07does help you out make sure you smash
- 0:08the like button also subscribe button
- 0:10and turn this post notifications on if
- 0:11you want to get notified when to upload
- 0:12more Roblox development content
- 0:14additionally I have a patreon if you
- 0:15guys like this for me and gain access to
- 0:16all the scripts and the game file that
- 0:17make during this episode there's link
- 0:19down below description and you guys can
- 0:20go and check that out as well with that
- 0:21being said let's get into it jumping in
- 0:23eating simulator we can see on the right
- 0:24hand side of the screen they have a
- 0:26button labeled coats and if we click on
- 0:28this we see a little guy pops up that
- 0:29says codes it also has a little
- 0:31description right here of where they can
- 0:32actually obtain those codes from and it
- 0:34also promotes the social media as well
- 0:36then if we enter a code inside of here
- 0:38we can click the redeem button and we
- 0:39will get a result displayed at the
- 0:41bottom depending on if the code was
- 0:42accepted if it was already used or if
- 0:44it's invalid or anything else like that
- 0:46so hopping directly into Studio the
- 0:47first thing that we're going to do is
- 0:48we're going to create the bun so what
- 0:50we're going to do is we're going to go
- 0:51inside of the star GUI inside of the bun
- 0:53GUI and inside of the button holder now
- 0:55we're going to go ahead and duplicate
- 0:56this shot butn because it looks pretty
- 0:58similar to the codes we'll rename this
- 1:00to codes then for the background color
- 1:02we are going to change this to a blue
- 1:04for the icon we are going to set that to
- 1:05a bird emoji and then the text of the
- 1:07title is going to say codes and the last
- 1:09thing we need to do is modify the layout
- 1:11order of the text button so it'll be
- 1:13three because we want this to appear
- 1:15after the shop but before the settings
- 1:17bun down below now that we're done with
- 1:18the Buns the next thing we have to do is
- 1:20actually create the GUI itself so what
- 1:22we're going to do is we're going to
- 1:23duplicate the settings GUI right here
- 1:24and rename this to codes then we will
- 1:26set the enabled property to truth so
- 1:28that we can actually see it then we'll
- 1:29go inside of here and for the frame we
- 1:31need to modify the background color of
- 1:33this to once again be another blue so
- 1:35something like that we'll also copy this
- 1:37because we need to change the container
- 1:39and the title frame to that as well so
- 1:41for the background we are going to put
- 1:42that color in just like that so that
- 1:44looks all good we're actually going to
- 1:45delete the container because we don't
- 1:46need that the next thing we'll do is we
- 1:48will modify the title instead of saying
- 1:50settings we want that to display codes
- 1:52then for the subtitle we're going to
- 1:53change this to what they had so thumb
- 1:55Emoji like the game another thumb Emoji
- 1:58plus redeem code here for rewards
- 2:02exclamation mark there we go and we want
- 2:04to modify this a little bit also the
- 2:06frames should probably be a little bit
- 2:09smaller so something like that I'd say
- 2:11is pretty good let's make sure that we
- 2:12Center this so set the position to 0.
- 2:15five there we go additionally for the
- 2:16subtitle they also have a little bit
- 2:18more to the text so we're going to say
- 2:19hint check description now I don't think
- 2:23this is a great message you could
- 2:24explain it a little bit better for where
- 2:25they can actually get codes from but we
- 2:27are just replicating what they created
- 2:29the next thing we'll do is we'll
- 2:30duplicate the subtitle and we want to
- 2:31bring it down a little bit under this
- 2:33subtitle so we are probably going to
- 2:35have it about like right there and we'll
- 2:37just rename this to socials because what
- 2:39they do is they basically promote their
- 2:40Twitter and YouTube right here so for
- 2:42instance I would say at monster deev and
- 2:45YouTube Monster Dev just like that it's
- 2:48similar to what they have then what
- 2:49we're going to do is we're going to
- 2:50duplicate subtitles one more time and we
- 2:52want this to actually be positioned
- 2:54relatively far down on the GUI so maybe
- 2:57like .9 we'll say and then let's make it
- 2:59a little bit smaller and increase it a
- 3:01little bit okay so there we go and now
- 3:03what this is actually going to be is
- 3:04this is going to be the result for
- 3:05whenever a player types in a code so
- 3:07we're going to modify the text of this
- 3:08actually so sometimes it's going to say
- 3:10invalid code or already redeemed or
- 3:12successful or things like that when it's
- 3:14invalid we want the text to be red and
- 3:16of course we'll change this to Green if
- 3:18it is valid additionally we want the
- 3:19text stroke to appear so we're going to
- 3:21set the text stroke transparency to zero
- 3:22so we can actually see that and now that
- 3:24looks pretty good the next thing we'll
- 3:25do is we will duplicate the exit button
- 3:27and rename this from exit button to
- 3:28redeem then for the background color we
- 3:30want to set this to a green so just
- 3:32something like that then we basically
- 3:34want this button to appear just above
- 3:35where our result is at so let's go ahead
- 3:37and position this in the center so
- 3:4005. that looks pretty good and then we
- 3:42have to add a text box to this as well
- 3:45let's make sure that for the size of the
- 3:47text box it is set to scale and now we
- 3:49just have to drag it a little bit above
- 3:51our redeem button so probably something
- 3:52like that we might be able to do a
- 3:53little bit more resizing but let's make
- 3:55sure that we position this in the center
- 3:57so 0.5 and5 there we go we know that
- 4:00that's centered the background color of
- 4:01this is going to be a little bit of a
- 4:03darker blue so like that now for the
- 4:05text we want the text to display enter
- 4:07code here we want the text color to be
- 4:09white we want the text to be scaled for
- 4:12the font we probably want it to be like
- 4:13a Gotham bold and then additionally we
- 4:15want to put a UI Corner inside of there
- 4:17as well so we'll just duplicate the one
- 4:18from the redeem bun put it inside of
- 4:20there and then I don't know maybe we
- 4:21could adjust this a little bit and I
- 4:22think that looks pretty good
- 4:23additionally for the redeem button we
- 4:25actually have to set the text to redeem
- 4:27and all caps and there we go if we want
- 4:29to make the redeem butn a little bit
- 4:30taller we can I don't know it depends on
- 4:32how you guys are feeling but either way
- 4:34I think that looks pretty good we have
- 4:35all the basic components and it's
- 4:37looking good eventually we'll set the
- 4:38result to not visible but for right now
- 4:40just so that we don't forget it and we
- 4:42remember that we do need to script this
- 4:43element we will leave it visible for now
- 4:45now that we have the GUI created let's
- 4:47go ahead and start scripting so we're
- 4:48going to go into the code GUI and inside
- 4:50of here we have three different scripts
- 4:52we have two local scripts and one module
- 4:53script the first thing that we're going
- 4:54to do is we're actually going to delete
- 4:56the Handler module script and we're
- 4:57going to go into the button local script
- 4:59and we basically have to modify one
- 5:00variable so this works for the code bun
- 5:02so inside of the settings bun we see
- 5:03that we're going inside the bun holder
- 5:05and instead of getting the settings bun
- 5:06we actually want to get the codes button
- 5:08then we'll also rename this variable
- 5:09from settings button to code button and
- 5:11since we rename this variable we have to
- 5:13fix it down here as well and there we go
- 5:14whenever we click on the code M this GUI
- 5:16will appear or disappear next what we're
- 5:18going to do is we're going to create a
- 5:19config to hold all of our codes that are
- 5:21able to be redeemed so we're going to go
- 5:22inside of the replicated storage inside
- 5:24of the config folder and add a brand new
- 5:25module script to this we'll rename it to
- 5:27codes and then inside of the table that
- 5:29the module is set to what we're going to
- 5:31do is we're going to start adding some
- 5:32of our codes to this so for example
- 5:34we'll just add one code and that's going
- 5:35to be called test and we're going to set
- 5:36the value of this to the amount of money
- 5:38we want to reward the player so let's
- 5:39just say if a player redeems this code
- 5:41right here they're going to get 1,000
- 5:42coins we'll also add another code as
- 5:44well and you have probably want to
- 5:45create codes like 100k likes or
- 5:47something I commonly see a lot of games
- 5:49doing this the thing is though is that
- 5:51since we started this off with a number
- 5:52this won't actually work what we have to
- 5:54do is we have to wrap this inside a
- 5:55brackets and then put this text inside
- 5:57of a string as well and then we can set
- 5:59the the value of it and we'll say we'll
- 6:00set this to 10,000 coins so if you want
- 6:02to have any codes that start off with
- 6:04numbers at first you just have to create
- 6:05them like this otherwise if the first
- 6:07character is a string you can just
- 6:08create it like normal so now we have the
- 6:09two codes that we want to use you guys
- 6:11can obviously add more codes if you want
- 6:12to we can now start scripting the GUI so
- 6:14we're going to go back inside of the GUI
- 6:16and open up the manager script and
- 6:18inside of here we have to clean some
- 6:19things up a little bit so first of all
- 6:20we already deleted the Handler so we no
- 6:22longer need that we will use the remotes
- 6:24and actually we're already getting a
- 6:25config right here we're not going to use
- 6:26the settings config we're actually going
- 6:27to use the codes config so we can kind
- 6:29of just change that variable around a
- 6:30little bit we will use the player we
- 6:32will use the screen GUI and the frame
- 6:33the container we will change and the
- 6:35template we will not be using at all
- 6:37either we'll also keep these constants
- 6:39for right now and we're actually going
- 6:40to delete all of this except for when we
- 6:42click on the exit Buton so now your
- 6:43script should look something like this
- 6:44then what we're going to do is we are
- 6:46going to remove this container variable
- 6:47because there is no container in here
- 6:49and what we actually need get is the
- 6:50text box because that's where the player
- 6:52is going to type in their code at so
- 6:53frame. text boox we also need to get the
- 6:55redeem button so local redeem button
- 6:58equals frame redeem and one of the last
- 7:01things that we're going to need is the
- 7:02result so we're going to say local
- 7:03result text equals frame do result now
- 7:07the reason that we kept the on and off
- 7:08color variables around is because
- 7:10remember depending upon what the result
- 7:11actually is the text color is going to
- 7:13need to change if it's a positive result
- 7:15like the player actually redeemed the
- 7:16code we want that text to be green but
- 7:18if it's something like this has already
- 7:19been redeemed or it's invalid we want
- 7:21the text to be red so let's rename these
- 7:22variables from on color to success color
- 7:26and from off color to reject color and
- 7:28now for the colors reject is red and
- 7:30success is green so that is all looking
- 7:32perfect next what we're going to do is
- 7:33we're going to go back inside of the
- 7:34replicated storage inside of the remotes
- 7:36folder we're going to create a new
- 7:37remote function now we'll rename this to
- 7:39redeem code and we'll be using that
- 7:41remote inside of the manager script what
- 7:43we want to do though is we want to
- 7:44listen for any time the redeem button is
- 7:46actually clicked and we will connect
- 7:47that to an anonymous function now
- 7:49whenever we click this this is when
- 7:50we're actually going to invoke that
- 7:51redeem code remote function so we're in
- 7:53sayate local result equals remotes do
- 7:56redeem code invoke server and we need to
- 7:58pass through the text that's inside of
- 8:00our text box which would be whatever the
- 8:02player actually typed out so the way
- 8:03that we can do this is by saying textbox
- 8:05do text and there we go we're now
- 8:07passing through the code to the server
- 8:08now let's consider and do things based
- 8:10on the results that we could possibly
- 8:11get and there's currently three results
- 8:13that I can think of and we'll create if
- 8:15statements for each of these so we're
- 8:16going to say if result equals and the
- 8:18first one is does not exist so if the
- 8:21code isn't actually real then we're
- 8:23going to do something we'll also make an
- 8:24L if statement inside of here we'll say
- 8:26the exact same thing so lsf result
- 8:28equals and now for the second
- 8:29possibility I would say that would be
- 8:31already redeemed so if the player
- 8:33already typed in that code then we want
- 8:35to do something and we'll do one more
- 8:37else if statement and for this result it
- 8:39would be redeemed so whenever the code
- 8:41is successfully redeemed this will be
- 8:42the result if a player tries to redeem a
- 8:44code that they've already redeemed this
- 8:45will be the result and if the player
- 8:47tries to redeem a code that doesn't
- 8:48exist this will be the result right here
- 8:50now no matter what the result is we
- 8:51pretty much want to do the same thing or
- 8:53similar things what we want to do is we
- 8:55want to modify the result text to say
- 8:57something like this code does not exist
- 8:59or this code is already redeemed or if
- 9:01they are able to redeem it we want it to
- 9:02say redeem additionally based off the
- 9:04result we'd also want to change the
- 9:05color of the result text as well so what
- 9:07we'll do is we will create a function
- 9:09local function display result and we're
- 9:12going to accept text which is of course
- 9:14going to be a string and color which is
- 9:16of course going to be a color three then
- 9:17what we're going to do is we're going to
- 9:18say result text. text and we're going to
- 9:21set that to the text that we're getting
- 9:22passed through to us additionally we're
- 9:23going to want to change the text color
- 9:25three of this as well and that'll be set
- 9:27to the color that's getting passed to us
- 9:29we also need to make sure that we make
- 9:30this visible so we'll set that to true
- 9:32and then also we want to make this not
- 9:34be visible after a couple of seconds and
- 9:36we can easily do this by saying test.
- 9:38delay we'll delay it by 3 seconds and
- 9:40create an anonymous function and we'll
- 9:41say result text. visible equals false so
- 9:44there we go whenever we call this
- 9:45function we set the text and we set the
- 9:47color and then we make it visible and
- 9:48then after a couple of seconds it
- 9:49becomes not visible again so when are we
- 9:51going to call this function well we'll
- 9:52call this function for each of these if
- 9:54statements so inside of here we'll say
- 9:56display result and the text that we're
- 9:57going to pass through is inval valid
- 9:59code and the color is of course going to
- 10:01be the reject color then for the already
- 10:03redeemed we can literally just say
- 10:05already redeemed and pass through the
- 10:07reject color and then for redeemed we
- 10:09are going to just say redeemed and we
- 10:11will pass through the success color so
- 10:13there we go we now have handled
- 10:14everything on the client and now we just
- 10:15have to handle this on the server side
- 10:17now what we want to do is we want to
- 10:18actually add the player data for keeping
- 10:20track of the codes that the player has
- 10:22redeemed so we're going to go inside of
- 10:23the server script service inside of the
- 10:24player dat of the script and inside of
- 10:26here we have to add the codes config Bo
- 10:28so we're going to say codes config
- 10:29replicat storage. config
- 10:38docoda store before what we're going to
- 10:40do is we're going to create a brand new
- 10:42codes folder and this will store all the
- 10:44codes so instance. new folder we'll of
- 10:46course parent that to the player we'll
- 10:48set the name of this folder to codes in
- 10:51all lowercase then we're actually going
- 10:52to Loop through the codes in the config
- 10:54file so we're going to say for code
- 10:56comma reward because remember the key is
- 10:58the code and the value would be the
- 10:59reward in pairs codes config do then we
- 11:02need to create a code instance so we're
- 11:04going to say code instance equals
- 11:07instance. new we'll create a bull value
- 11:09and we'll parent that to the codes
- 11:11folder then we'll set the name of this
- 11:13code instance to the actual name of the
- 11:15code so it's going to be code and that's
- 11:17all good we don't even have to set the
- 11:18value for this then we'll go inside of
- 11:19the if success statement where we
- 11:21actually process the player's data and
- 11:22we'll add this to right below where we
- 11:24actually start adding in the players pet
- 11:26inventory so we'll say if return value.
- 11:28codes then and now we're going to Loop
- 11:29through all the instances in the
- 11:31player's code folder so we're going to
- 11:32say foror code in I pairs codes folder
- 11:36get children do so we say code. value
- 11:39and we're going to modify the value
- 11:40based on the return data so we're going
- 11:41to say equals if return value do codes
- 11:44and we're going to index that with the
- 11:46code. name so the actual code itself
- 11:48doesn't equal nil then return value do
- 11:51codes once again index that with the
- 11:53code. name else false so whenever the
- 11:55player loads in this will update it with
- 11:57their previous data and then we just
- 11:58have to to actually save the player data
- 12:00so we'll come below here we'll say local
- 12:02codes equals table then foror code in I
- 12:06pairs player do codes get children do
- 12:09and then we'll say codes Index this with
- 12:11the code. name and then set that to the
- 12:13code. value and then we just have to add
- 12:15that to our data table right down here
- 12:17so we'll say codes equals codes and then
- 12:19that should be good now let's go ahead
- 12:20start up our game and make sure that the
- 12:22data is working correctly so we can go
- 12:23into players into monster into codes and
- 12:25we can see that we have both of the bull
- 12:26values generated right there with the
- 12:28two different codes so that's working
- 12:30perfectly now that we created the player
- 12:31data we actually need to create a server
- 12:32script for handling all the serers side
- 12:34code functionality so inside of the
- 12:36server script service we're going to
- 12:37create a brand new script and we'll
- 12:38rename this to codes now inside of the
- 12:40script we're going to need to work with
- 12:41remotes and the config file itself so
- 12:43we're going need to get the replicated
- 12:44storage so we'll say local replicated
- 12:46storage and we'll also need a server
- 12:47script service in here as well so server
- 12:49script service and create a variable for
- 12:51that then we'll get the remotes folder
- 12:52so we'll say local remotes equals
- 12:53replicated storage. remotes and we also
- 12:55need to get the codes config module so
- 12:57let say local codes equals replicated
- 12:59storage. config doc codes and we do need
- 13:01to wrap that in a require statement so
- 13:03just like that and then finally we are
- 13:04going need to get the rewards utils
- 13:06because we're going to reward the player
- 13:08coins whenever they actually redeem a
- 13:09code so serers script service. utils do
- 13:11rewards and there we go then we can
- 13:13actually listen for the redeem code
- 13:14remote function to actually be invoked
- 13:16so we'll say remotes do redeem code. on
- 13:19server invoke and we need to set this to
- 13:20a function so let's create a brand new
- 13:22function up here we'll say local
- 13:23function redeem code and we won't set
- 13:26the parameters of that yet but we just
- 13:27want to fix this error real quick so
- 13:29there we go now that's all good now for
- 13:30the parameters of this function we're
- 13:32going to say player which is of course
- 13:33going to be a player and code which is
- 13:35going to be a string now the first thing
- 13:37is that we want to check if this code
- 13:38actually exists and this is really easy
- 13:40to do we'll say if codes and index that
- 13:43with the code that the player passed to
- 13:44us now this if statement is saying if
- 13:46the code exists then do something but
- 13:48what we want to do is we want to say if
- 13:49the code does not exist then we want to
- 13:51do something so that's why we're putting
- 13:53the not right there and what we'll
- 13:54actually do is we will return does not
- 13:57exist so if the code that the player
- 13:58pass to us doesn't exist then the
- 14:00function is going to stop right there
- 14:01and the next thing we want to do is we
- 14:02want to check if the player has actually
- 14:03redeemed the code or not and the way
- 14:05that we can do this is by saying if
- 14:06player do codes and then this of course
- 14:08is going to be the folder which holds
- 14:09all the different codes and we'll index
- 14:11that with the specific code do value so
- 14:13this will be checking if the value is
- 14:15either true or false then so if the bull
- 14:17value instance is set to true then we
- 14:19know that the player has redeemed the
- 14:21code so we're going to return already
- 14:23redeemed so now if the code is invalid
- 14:25or the player has already redeemed the
- 14:26function will not make it past those two
- 14:28if statements but if the function does
- 14:30make it past those two F statements we
- 14:32know that we now need to reward the
- 14:33player and set the code to redeemed and
- 14:35notify the player has redeemed the code
- 14:36so the first thing we'll do is we'll go
- 14:38inside of the player's codes folder and
- 14:40we'll get the bull value instance and
- 14:41then we can set the value of this to
- 14:43true so that we know the player has now
- 14:45redeemed the code then what we'll do is
- 14:46we will reward the player with the coins
- 14:48that they deserve so player and the way
- 14:50that we can get the amount of coins that
- 14:52the player should be rewarded is by
- 14:53actually just indexing codes with the
- 14:55code because that will return the value
- 14:57so we're going inside of the codes
- 14:58config and finding the value of the
- 15:00specific code then finally we want to
- 15:02return redeemed because the player has
- 15:04now successfully redeemed the code so
- 15:05with all this being set up we can go
- 15:07ahead start up our game and test this
- 15:08out so we can see we load in and we see
- 15:10the invalid code is already displayed to
- 15:11us that's because we haven't changed the
- 15:13visibility to false yet but ignore that
- 15:15what we can do is we can type in T and
- 15:17just see what happened we can see that
- 15:18the invalid code and it's red appears
- 15:20for us and it also disappears after a
- 15:22couple of seconds let's go ahead and
- 15:23redeem the test code when we click the
- 15:24redeem button we can see redeemed is
- 15:26sent to us and we can also see that we
- 15:28get money for this as well now if we try
- 15:29to redeem it again it says already
- 15:31redeemed so we know that that is working
- 15:33perfectly the last thing that we need to
- 15:34actually do is go back inside of the
- 15:35star GUI inside of the code GUI inside
- 15:38of the frame and we just have to set the
- 15:39result visibility to false by default
- 15:41because we don't want to see that by
- 15:43default and then additionally we are
- 15:44going to set the code screen GUI to not
- 15:46enable so we don't see that either so
- 15:48with that being said ladies gentlemen
- 15:49you now have a functioning Code system
- 15:51for your game hopefully this video did
- 15:52help you guys out if it did make sure
- 15:53you smash like button also subscribe
- 15:55button and turn this post notification
- 15:56on if you want to get notified when I
- 15:57upload more Roblox m content
- 15:59additionally have a patreon if you guys
- 16:00like to SW me and gain access to all the
- 16:02scripts and the game file that I made
- 16:03during this video there's a link down
- 16:04below description and you guys can go
- 16:05check that out with that being said I'll
- 16:06see you guys in the next episode
- 16:11[Music]
About this transcript
This page contains the full transcript of Adding Twitter Codes! Roblox Studio Simulator Guide Episode 30 by MonzterDEV, generated from the public captions YouTube serves with the video. The transcript has 4,320 words across 565 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.