Scripting the Pet Egg Gui! Roblox Studio Simulator Guide Episode 25 — Transcript
Full transcript
- 0:00what's going on ladies and gentlemen
- 0:00welcome back to the simulator series in
- 0:02today's episode we are going to be
- 0:03scripting the pet egg gy that we made in
- 0:05the last episode as always if you guys
- 0:07do enjoy the video or it does help you
- 0:08out make sure you smash the like button
- 0:09also the subscribe button and turn this
- 0:10post notifications on if you want to get
- 0:12notified when i upload more roblox
- 0:13vlogma content additionally i have a
- 0:15patient if you guys like this for me and
- 0:16gain access to all the script and the
- 0:17game file that make during this episode
- 0:19there's a link down below in description
- 0:20and you guys can go and check that out
- 0:21with that being said let's get into it
- 0:23so hopping directly into eating
- 0:24simulator to show off the functionality
- 0:25in the last episode we created this gui
- 0:27that you're seeing right here and what
- 0:29we're going to be doing in this episode
- 0:30is scripting it so the entire gui is
- 0:32populated with all of the individual
- 0:34pets as well as when we hover over them
- 0:35it'll display the chance of hatching
- 0:37that pet and we'll also implement
- 0:38hatching an egg and selecting a random
- 0:40pet for that egg and this entire system
- 0:42will work for multiple eggs so not just
- 0:44the basic egg but also another egg as
- 0:46well so that we can see how we can
- 0:47easily do this with multiple different
- 0:49eggs happen directly in the studio the
- 0:51first thing that we want to do is we
- 0:52want to actually add some pets to our
- 0:54game now i'm going to be using this free
- 0:55to use pet pack by azias hopefully i'm
- 0:57pronouncing the name correctly i'll
- 0:58leave a link down below in the
- 0:59description to get the pet pack now from
- 1:01this pet pack we're gonna choose just a
- 1:03couple of pets out of it because we're
- 1:04not gonna use all of them during this
- 1:06tutorial so the ones that i'm gonna take
- 1:07are the bunny the cat the dog the fox
- 1:10the pig and the turtle so we're gonna
- 1:12highlight all those hit control x then
- 1:14inside of the replicated storage we're
- 1:15gonna create a folder and we'll rename
- 1:17this to pets and we'll paste all the
- 1:19pets that we just selected directly into
- 1:21this folder so now that we've got a
- 1:22couple of our pet bottles what we then
- 1:23want to do is inside of the config
- 1:25folder we actually want to create a
- 1:26config module for the eggs so we'll
- 1:28insert a new module script and we'll
- 1:30rename this to eggs and then inside of
- 1:32the module table we'll create our first
- 1:34egg so we'll say basic underscore egg
- 1:36equals which is going to be another
- 1:38table and then this table is actually
- 1:39going to be an array of more tables so
- 1:41we'll create a new table inside of here
- 1:42and inside of here we're going to add
- 1:44some properties for each of the
- 1:45individual pets that you can hatch from
- 1:47this specific egg so first we're going
- 1:48to say id and we're going to set that to
- 1:50the id of the pet that we want to hatch
- 1:52from this egg so let's say that the dog
- 1:54is one of the pets that we want to hatch
- 1:55from this egg we can also set the rarity
- 1:57as well so for the dog we want a common
- 1:59dog to come from this egg and then we'll
- 2:00set the chance of hatching a dog from
- 2:02this egg and now this will actually be
- 2:03the most common pet from this egg at a
- 2:0515 chance then we can just copy and
- 2:07paste this table and just change around
- 2:09some of the information so the next pet
- 2:10that we want to be able to hatch from
- 2:11this is a bunny it'll also be common but
- 2:13the chance of this is actually going to
- 2:15be 10 instead of 15. we can duplicate
- 2:17that once again then for the cat it'll
- 2:19be the exact same as the bunny we want
- 2:20it to be common and we want it to be a
- 2:2210 chance we'll copy it again this time
- 2:24we want to hatch a fox with a 7.5 chance
- 2:28then a turtle which is actually uncommon
- 2:30and that'll have a 5 chance and lastly
- 2:32will be the pick which will be rare and
- 2:34it'll have a three percent chance of
- 2:36hatching now obviously you can set up
- 2:37the egg however you want to and all the
- 2:38pets as well this is of course just for
- 2:40demonstration purposes now we use this
- 2:42config file later to display all the
- 2:44pets which can be hatched from the egg
- 2:45along with their rarities and along with
- 2:47their chances of actually hatching those
- 2:48and then on the server side we'll also
- 2:50use this when deciding what pet to
- 2:52actually hatch from the x so now we need
- 2:53to actually create a handler for the gui
- 2:55or the billboard gui that we created in
- 2:57the last episode so inside of the
- 2:58starter gui we have the eggs folder and
- 3:00then we have our little template
- 3:01billboards ui right here let's go ahead
- 3:03and create a local script and we'll just
- 3:05rename this the handler then inside of
- 3:07here we want to get the workspace
- 3:08service so we're going to say local
- 3:10workspace equals game get service
- 3:11workspace and we're also going to get
- 3:13the replicated storage as well now we
- 3:15need the workspace because we want to
- 3:16actually get the eggs folder right here
- 3:18which holds all of the egg models that
- 3:20we're going to want to add a gui to such
- 3:22as the basic and the rare egg right here
- 3:24so we'll create a variable for the eggs
- 3:25folder so we'll say eggs folder equals
- 3:28workspace.x and now we have the eggs
- 3:30folder and we're also going to need to
- 3:31get the pep models so we'll get that
- 3:33from the replicated storage so pet
- 3:35models equals replicated storage dot
- 3:38pets and we could even name this pets
- 3:39border to keep it consistent with the
- 3:41eggs folder variable that we just
- 3:42created but we'll leave it named as pet
- 3:43models we're also going to need to get
- 3:45that egg config that we just created so
- 3:46we'll say local a config equals require
- 3:50replicatedstorage.config.x and then
- 3:51lastly for right now we're going to
- 3:52actually get the template gui which is
- 3:55in the same folder as our handler so
- 3:56we'll say local template you could name
- 3:58this template gy it doesn't really
- 4:00matter equal script dot parent dot
- 4:03template and now we have the template
- 4:04billboard gui then let's go ahead and
- 4:06create our first function which is
- 4:07actually going to be called generate
- 4:09billboard gui inside of here we'll
- 4:11accept the egg model which is going
- 4:12gonna be a model but we're actually
- 4:14gonna get the instance of a model and
- 4:15then we'll also pass through the egg
- 4:17config as well which is gonna be a table
- 4:19let me show you an example of how we're
- 4:20gonna actually be calling this function
- 4:22so we're gonna say generate billboard
- 4:23gui and for right now we'll use the eggs
- 4:25folder and we'll just pass through the
- 4:27basic egg and that'll be the egg model
- 4:29and then for the egg config we'll pass
- 4:30through the egg config dot the basic x
- 4:32so of course for the config it'll
- 4:34actually be this array right here by the
- 4:36way that we're calling this and then
- 4:37also remember inside of our egg models
- 4:39which is inside of here each of the egg
- 4:40models has an attachment inside of it so
- 4:42inside of our function let's go ahead
- 4:44and create a variable for that
- 4:45attachment so we'll say local attachment
- 4:47equals egg model dot attachment then
- 4:49once we have that attachment we want to
- 4:50actually create a clone of our template
- 4:52billboard gui so we'll say local clone
- 4:55equals template clone and then we want
- 4:57to make sure that we parent this and
- 4:58we're actually going to parent it to
- 4:59this folder that we're currently inside
- 5:01of right now which is going to be the
- 5:02eggs folder so we're going to maintain
- 5:04all of the billboard guise inside of
- 5:06this one folder and since we're
- 5:07parenting it to the folder that we're
- 5:08currently inside of we need to make sure
- 5:10that we set the adorny to the attachment
- 5:12so that the billboard gui is displayed
- 5:14on that specific attachment and then we
- 5:16also want to rename the gui from
- 5:17template to whatever the egg actually is
- 5:19called so we'll just say eggmodel.name
- 5:21then let's look inside of the actual
- 5:23template inside of here we can see that
- 5:24we have the frame and then we have the
- 5:25title frame which inside of here we have
- 5:27the title text label and the same goes
- 5:28for the price as well so let's set the
- 5:30both of those so we'll say clone dot
- 5:33frame dot title dot title dot text
- 5:36equals eggmodel.name and remember we
- 5:39learned about g sub in the last couple
- 5:40of ui tutorials this basically allows us
- 5:42to find and replace a specific character
- 5:44or set of characters within the string
- 5:46that we're using this method on so we'll
- 5:47say underscore and we're going to
- 5:48replace that with a space and then we
- 5:50also want to set the price as well so
- 5:52we'll say clone.frame.price.price.txt
- 5:56equals and now we need to make a way to
- 5:58figure out the price of the egg so what
- 6:00we'll do is we'll actually modify the
- 6:02egg config slightly so inside of the
- 6:03basic egg config we'll add a new field
- 6:06to this and we'll say price and we'll
- 6:07just say the price of this is 2 000
- 6:09coins now for all the pets we want to
- 6:11actually create another field inside of
- 6:13here and we want to say pets and we're
- 6:14going to set that equal to basically
- 6:16what the egg originally was which was
- 6:18just an array of all these different
- 6:20pets so the basic egg is now a table
- 6:22with a field of price and pets and pets
- 6:24is now the table which is also an array
- 6:26of all the individual pets with the
- 6:28rarities the ids and the chances so now
- 6:30going back to the handler we can now get
- 6:32the price of the egg by saying
- 6:34eggconfig.price so now let's go ahead
- 6:36and test this out the first thing that
- 6:37we want to make sure that we do though
- 6:38is for the original template we still
- 6:40have the adorney set for the basic egg
- 6:42so what we'll do is we'll just actually
- 6:43set that to nothing so that this doesn't
- 6:45automatically display on the basic egg
- 6:46when we start the game and we can verify
- 6:48that the script is working and of course
- 6:49make sure that you're actually calling
- 6:51the method and make sure that you're
- 6:52passing through the basic egg model and
- 6:53the basic egg config just exactly like
- 6:55how we did then we can go ahead and
- 6:56start this up and verify that it works
- 6:58so upon starting up our game we can walk
- 7:00over to the basic egg and we can see
- 7:02that the price is directly down here we
- 7:04have the name set to basic egg although
- 7:05i'm pretty sure we set that by default
- 7:07anyway but we are seeing that this gui
- 7:09is popping up which means that
- 7:10everything is working correctly let's
- 7:12quickly adjust the price though to make
- 7:13the string actually be displayed how we
- 7:14wanted to so we want to actually display
- 7:16our like little money icon right there
- 7:18and then we'll combine that with the
- 7:20price and that's how the price should be
- 7:22displayed the next thing we want to do
- 7:23is we want to start populating the gui
- 7:25with all the pets that can actually
- 7:26hatch from this egg so let's go inside
- 7:28of the replicated storage and we
- 7:29actually need to get and we actually
- 7:31need to set the primary part of every
- 7:33single pet model for each of the
- 7:35different pets because we're going to be
- 7:36displaying these within a viewport frame
- 7:38so let's go ahead and drag all these
- 7:40outside of the replicated storage back
- 7:42into the workspace so that we can
- 7:43actually view and see them and then
- 7:44we'll start with the bunny what we want
- 7:45to do is we want to try to set the
- 7:47primary part to be the main square of
- 7:50the actual pet so we're going to try to
- 7:51avoid setting something like the feet or
- 7:53the ears or other things like that we
- 7:55want to just try to set it to the main
- 7:56square and if you're unfamiliar with
- 7:57setting the primary part of a model you
- 7:59click on the model it has the primary
- 8:01part property right here and then you
- 8:02just click that and select whatever part
- 8:04you want to set the primary part to so
- 8:05we've got the bunny done and then for
- 8:07the cat we found the face so let's just
- 8:09go ahead and do that for the dog we
- 8:11found this one as well and then we just
- 8:12have to do it for the fox the pig and
- 8:14the turtle all right so now that we have
- 8:15the primary part set for all of those
- 8:17pets we can go ahead and drag them back
- 8:19directly into the replicated storage and
- 8:20then we can go back to the handler and
- 8:22start working on generating all those
- 8:24pets so we'll create a new function
- 8:25above the generate billboard gui
- 8:27function called generatepet and what
- 8:29this will accept is the container which
- 8:31is going to be a frame and the pet
- 8:32config which is going to be a table and
- 8:35what i'm referring to by the pet config
- 8:36is going to be any of these specific
- 8:38tables now how we're planning to call
- 8:39the function is we're going to use a for
- 8:41loop so we're going to say for
- 8:42underscore pet in ipairs eggconfig.pets
- 8:46and then we'll just say generatepet and
- 8:48we'll pass through the
- 8:50clone.frame.container because remember
- 8:52inside of the billboard gy we have this
- 8:54container frame right here and then we
- 8:56also want to pass through the pet which
- 8:57is going to be given to us by using this
- 8:59for loop and then also inside the
- 9:00container we already have a text button
- 9:02named template inside of here so inside
- 9:04of regenerate pet function we're going
- 9:05to say local clone equals
- 9:08container.template cologne will then set
- 9:10the parent of the template to the
- 9:12container we want to set the name of the
- 9:13clone to petconfig.id
- 9:16we want to make sure that it's visible
- 9:17so we'll say clone.visible equals true
- 9:19and then inside of the template we have
- 9:21the pet name and the pet rarity text
- 9:23labels so we want to say
- 9:25clone.petname.txt and we want to set
- 9:27that to the
- 9:28petconfig.id and we'll probably want to
- 9:30use the g sub method on this as well in
- 9:32case any of your pets have underscores
- 9:34in their name so we can just say
- 9:35underscore and replace that with a space
- 9:38and then we also want to set the pet
- 9:40rarity.txt to the
- 9:43petconfig.rarity and then also for the
- 9:45rarity as well we want to change the
- 9:47color of the rarity text based on the
- 9:49rarity of the pet so what i mean by that
- 9:51is that the common rarity is sort of a
- 9:53darkish gray the uncommon is a green and
- 9:55then the rare is a blue so then let's
- 9:57create a function above this function
- 9:59called get rarity color and we're just
- 10:01going to pass through the rarity which
- 10:02is going to be a string and then we'll
- 10:04say local color and we'll say if rarity
- 10:07equals common then color equals color
- 10:10three dot from rgb two five five two
- 10:13five five two five five as that's white
- 10:15and then we can pretty much just copy
- 10:16and paste this so we'll say else if
- 10:18rarity equals uncommon then and this
- 10:21time we want a like lightish green so
- 10:24maybe something like that and then we
- 10:25can say else but i'm just gonna create
- 10:27another else if statement here and we'll
- 10:29say else if rarity equals rare and then
- 10:32for this we want a kind of lightish blue
- 10:35so something like that and then finally
- 10:37we just have to return the color then
- 10:38we'll do is back inside the generate pet
- 10:40function below where we set the text of
- 10:42the pet rarity we're gonna say clone.pet
- 10:45rarity dot text color three equals get
- 10:48rarity color and we'll just pass through
- 10:50the
- 10:51petconfig.rarity so now we're setting
- 10:52the color of the text based on the
- 10:54rarity and now just to quickly make sure
- 10:55everything's going good let's go ahead
- 10:57and start up our game we can then come
- 10:58over to the gui and we can see that this
- 11:00is all working correctly the only thing
- 11:01that we really need to do is set the
- 11:02visibility of the default template to
- 11:04false so that the first one isn't
- 11:06displayed but we can just ignore this
- 11:07one for now anyway we can see the dog
- 11:09bunny cat fox turtle and pig are all
- 11:11displayed starting from common to
- 11:13uncommon to rare and the only thing i'm
- 11:15noticing is that we probably want to
- 11:16just change the common color from a
- 11:18white to a gray because i kind of messed
- 11:19that up but other than that everything's
- 11:21looking pretty good we also need to add
- 11:22the viewport frame and that's what we'll
- 11:24be doing next as well so we'll quickly
- 11:25adjust the common color from being white
- 11:27to being more of a darkish gray and that
- 11:29looks pretty good and now we can start
- 11:31working on creating the viewport frame
- 11:32so let's actually create a function up
- 11:34here called generate viewport frame
- 11:36inside of here what we'll accept is
- 11:37actually a viewport frame which of
- 11:39course is going to be a viewport frame
- 11:41and the pet model which is going to be a
- 11:43model so back inside of the generate pet
- 11:44function what we want to do is we want
- 11:46to get a clone of the specific pet model
- 11:49from a replicated storage so we'll say
- 11:51local pet clone equals replicate storage
- 11:54dot pets and then we'll index that
- 11:56folder with the petconfig.id
- 11:59and then with the model that we find
- 12:00we're gonna clone actually i forgot we
- 12:01made a variable for this so we don't
- 12:03have to say replicatedstorage.patch we
- 12:04just have to say pet models and then we
- 12:06have the folder so that we can index it
- 12:08with the id and clone it and we'll pass
- 12:09the viewport frame of the clone so
- 12:12clone.viewportframe and then we'll also
- 12:13pass through the pet model as well so
- 12:15the pet clone that we just created of
- 12:17course make sure your viewport frame is
- 12:18spelled correctly when you're passing it
- 12:20through here otherwise you're gonna have
- 12:21an error now back to the generate
- 12:22viewport frame function what we want to
- 12:24do is we want to set the primary part c
- 12:26frame of the pet model so we're going to
- 12:28say pet model set primary part c frame
- 12:30this is why we set the primary part on
- 12:32the model otherwise we wouldn't be able
- 12:34to do this and we're going to create a
- 12:36brand new c frame and what this c frame
- 12:38is gonna be is this is actually gonna
- 12:39set the position of the model that we
- 12:41just created so we could say zero zero
- 12:44zero or we don't have to put anything in
- 12:46here and by just saying c frame dot new
- 12:48that is the equivalent of saying c frame
- 12:50dot new and putting 0 0 0 inside of it
- 12:53so that's going to set the position of
- 12:54the model and then we'll multiply this c
- 12:56frame by c frame dot angles and this
- 12:59actually allows us to set the angle at
- 13:01which the model is currently positioned
- 13:02at so based on how our pets are
- 13:04currently set up and how we're going to
- 13:05be setting up our viewport frame and the
- 13:07camera for the viewport frame we want
- 13:08the x angle to be zero the y angle to
- 13:11actually be math.rad 90 because we want
- 13:14it to be turned to the side a little bit
- 13:16and then for the z angle we want this to
- 13:17be zero as well and now if this is
- 13:19confusing to you don't worry viewport
- 13:21frames are a little bit more complicated
- 13:23and see frames is also another thing
- 13:24that's a little bit complicated so if
- 13:26you don't know too much about these
- 13:27don't let yourself get too stumped just
- 13:29kind of keep following along with the
- 13:30tutorial and you can learn about the c
- 13:32frames and viewport frames on your own
- 13:34time in my opinion these are some really
- 13:35nice things and eventually you should
- 13:37know them but don't get stuck on them
- 13:38for too long if you are stumped just try
- 13:40to get it set up however you like it or
- 13:42however it'll work for your system and
- 13:44then try to move on from there and come
- 13:45back to them at a later time because
- 13:47from my experience when i was first
- 13:48starting to try to learn c frames and
- 13:49work with the viewport frames i had a
- 13:51lot of difficulty and had a lot of
- 13:53frustration as well so if you're in the
- 13:55same boat as me don't feel bad just try
- 13:56to keep moving on and keep learning
- 13:58eventually anyway now that we set the c
- 14:00frame of the primary part the next thing
- 14:01we need to do is we actually need to
- 14:02parent the pet model so we'll say
- 14:04petmodel.parent and we're going to set
- 14:05that to the viewport frame then we need
- 14:07to create a camera for the viewport
- 14:09frame so we'll say local camera equals
- 14:11instance dot new and we'll create the
- 14:13camera and we're going to set parent of
- 14:14the camera to the viewport frame and we
- 14:16want to set the viewport frame property
- 14:18called current camera to the camera that
- 14:20we just created and then we also need to
- 14:21set the c frame of the camera that we
- 14:23just created so we'll create a new c
- 14:25frame by saying c frame dot new and
- 14:26we'll set the position of the c frame by
- 14:28using vector three and we'll set that to
- 14:30zero zero and four and now up here i
- 14:33understand that when we're setting the
- 14:34position we're using a c frame dot nu
- 14:36which is slightly different than a
- 14:38vector3.0 but imagine that we set the
- 14:40position of the primary part c frame to
- 14:42zero zero zero now we're setting this to
- 14:44zero zero four which in a way sets the
- 14:46camera about four studs away from the
- 14:49actual pet model and if this is
- 14:50complicated for you at all think about
- 14:52it in this if you're taking a picture or
- 14:53something you don't wanna literally be
- 14:55inside of the thing you're taking a
- 14:57picture from right you want to be a
- 14:59little bit further away so that's why
- 15:00we're setting the position four studs
- 15:02away from what we actually set the pep
- 15:03model to and then for the orientation of
- 15:05the camera we're gonna set that to the
- 15:07pet model and we're gonna get the
- 15:08primary part of the pet model and we'll
- 15:10get the position of the pet model once
- 15:12again if you're confused at all by the
- 15:13viewport frames or the cameras and the c
- 15:16frames and everything like that don't
- 15:17feel bad i even struggle a little bit
- 15:18with this to really articulate or teach
- 15:21people why all this stuff comes together
- 15:23and what everything exactly does maybe
- 15:25something in the comment section could
- 15:26explain it better for anybody who wants
- 15:27to know more or understand it a little
- 15:29bit better i'm still not perfect or even
- 15:31really good when it comes to c frames
- 15:33and knowing everything that goes into it
- 15:35but i'm trying to explain the things
- 15:36that i really do understand and at least
- 15:38give us a working product so that you
- 15:39guys don't have to go through all the
- 15:41struggles of learning it all on your own
- 15:42alright so now that we have that
- 15:43function created remember we already
- 15:45called this when we first created the
- 15:46function so we cloned the actual pet
- 15:47model found inside of the replicated
- 15:49storage and then we passed that through
- 15:50to this function we also passed through
- 15:52the viewport frame as well so let's go
- 15:53ahead and start our game and see how
- 15:55these turned out so if we come over to
- 15:56our pet gui we can actually see all the
- 15:58pet models are displayed very nicely
- 16:01right on our gui which is really really
- 16:03good now let's make some minor
- 16:04adjustments to the actual gui itself so
- 16:06inside of the gui we have the container
- 16:08and then we have the default template
- 16:10right here let's make the template not
- 16:11visible by default and also for the
- 16:13viewport frame we want the background
- 16:15transparency to be one because we don't
- 16:16want to see that white background behind
- 16:18our pets and additionally remember
- 16:20inside the generate viewport frame
- 16:21remember how it was describing the
- 16:23vector3 that we created here gives us a
- 16:25little bit of a distance away from our
- 16:26pet model if we maybe wanted to make the
- 16:28pet appear a little bit larger or say
- 16:30take a picture from closer towards the
- 16:32pet we could change four to three and
- 16:34that'll basically put us a little bit
- 16:36closer to the pet and kind of display
- 16:37them as a little bit larger inside of
- 16:39the gui and now we see maybe even three
- 16:42might be a little bit better because
- 16:43they appear a little bit larger but the
- 16:44other thing that you kind of have to
- 16:45worry about is with the bunny we can see
- 16:47the ears are kind of poking out of the
- 16:49frame a little bit so you do have to
- 16:51worry about that a little bit if the
- 16:52distance isn't far enough away from them
- 16:53then all the aspects of them might not
- 16:55appear inside of the frame but if you're
- 16:57too far away from them they might appear
- 16:58a little bit too small for your liking
- 17:00so you want to find a good balance
- 17:01between both of those things i actually
- 17:03don't mind the bunny's ears popping off
- 17:04a little bit and i really like the size
- 17:06so i think we'll leave it as it's so the
- 17:08next thing we want to do is back inside
- 17:09of the generate pet function we actually
- 17:11want to set up displaying the chance of
- 17:13hatching a specific pet whenever you
- 17:15hover over that pet in the gui so we're
- 17:17gonna say clone.mouse enter which is an
- 17:20event of all buttons and actually to
- 17:21make this a little bit easier we can set
- 17:23the type of the clone to be a text
- 17:25button as that's what the clone actually
- 17:27is so now it'll automatically fill in
- 17:29when we're typing this stuff out so now
- 17:30we see we have mouse enter so then we
- 17:32can easily say connect create an
- 17:34anonymous function inside of here and
- 17:35what we want to do is whenever the mouse
- 17:37is hovering over the text button we want
- 17:39to actually set the pet rarity text to
- 17:41the chance of hatching the pet so we're
- 17:42going to say clone.pet
- 17:44rarity.text equals petconfig.chance
- 17:48and then whenever the mouse is not
- 17:50hovering any longer we want to say mouse
- 17:52leave we're going to set the pet rarity
- 17:54text back to the actual rarity just like
- 17:56that so once again we can set up our
- 17:58game test this out and verify that that
- 18:00all works going into our game hovering
- 18:01the mouse over it we can see that the
- 18:03rarity has been changed from rare to
- 18:05three and the same goes with all of
- 18:06these as well now the only other thing
- 18:08that we might want to do is actually add
- 18:09a percent symbol after the number so
- 18:11people understand it's gonna be like a
- 18:13three percent chance and etc and there
- 18:15we go now that's all good so now we
- 18:17should be pretty much done with the
- 18:18generate pet function let's go back to
- 18:19the generate billboard gui function and
- 18:21now if we just look back at the
- 18:22billboard gui we can see that we have
- 18:24the buttons frame right here which holds
- 18:26three different buttons and we of course
- 18:28want to do something when these buttons
- 18:29are clicked so we're gonna say clone dot
- 18:31frame dot buttons and we can start with
- 18:34auto dot mouse button one click connect
- 18:36function and then let's just duplicate
- 18:38this two more times so that we can
- 18:39listen to all the buttons being clicked
- 18:40so then we have times one and finally we
- 18:42have times three now for the auto button
- 18:44we most likely want to check if the
- 18:46player actually has this unlocked and if
- 18:48they do not have this unlocked we want
- 18:50to prompt them to purchase the game pads
- 18:52so depending on how you guys have your
- 18:54data set up for the game passes you
- 18:56could say if player and we actually have
- 18:57to get the player so let's go back up to
- 18:59the top and get the players service and
- 19:02we just create a variable for the player
- 19:03so local player equals players dot local
- 19:06player then coming back down to here we
- 19:07can say if player dot game passes dot
- 19:11times three dot value then so this mean
- 19:14if the player does own the game pass but
- 19:15let's say if the player does not own the
- 19:17game pass then we would want to prompt
- 19:19them to purchase the game pass so then
- 19:22you can prompt them to purchase the game
- 19:23pass otherwise if the player does
- 19:24actually own the game pass we'll do
- 19:26something else and we'll get to that in
- 19:27a minute and i actually made a mistake
- 19:29here i said times three realistically we
- 19:30would be checking the auto but we would
- 19:32also do the exact same thing with times
- 19:34three as well so instead of saying auto
- 19:36we're gonna check if they own the game
- 19:38pass by going through their player data
- 19:39and checking the game passes and then
- 19:41checking the times three and if they
- 19:42don't own it then we're gonna prompt
- 19:43them to purchase it otherwise we'll do
- 19:45something else as well now for times one
- 19:46this is gonna be the free hatching that
- 19:48everybody has access to you just open
- 19:50the egg one time simple and basic now we
- 19:52need to create a remote event so that we
- 19:53can communicate from the client to the
- 19:55server and tell the server hey we want
- 19:56to open up this ped egg right here so
- 19:58going back inside of the replicated
- 19:59storage inside the remotes we can create
- 20:01a new remote event and we'll just rename
- 20:03this to buy egg and then of course we
- 20:05need to create a variable for it so
- 20:06we'll just say local buy egg equals
- 20:09replicate storage that remote stop buy
- 20:11egg then back inside of the times one
- 20:13button click listener we're gonna say
- 20:15buy egg fire server and we'll just pass
- 20:17through the egg model dot id and we'll
- 20:19just pass through the egg model dot name
- 20:22and then for the auto end times three we
- 20:23would actually do the exact same thing
- 20:25but we'll pass through an extra argument
- 20:27so inside of the times three if the
- 20:28player does own this game patch what we
- 20:30would want to do is we would want to
- 20:32fire the server but instead just passing
- 20:34through the name of the egg we'll also
- 20:35pass through times three so that we know
- 20:37that this is sort of like the little
- 20:38modifier that we're gonna use while
- 20:40hatching the egg and this is a specific
- 20:41button that we pressed and we'll do the
- 20:43exact same thing for the auto but
- 20:45instead of passing through times three
- 20:46we'll pass through all them now i'm
- 20:48gonna actually comment out all of this
- 20:49stuff right here as we're not gonna
- 20:50implement the data of checking if we own
- 20:52the game pass or not the same goes for
- 20:54the times three as well so we're just
- 20:56gonna leave that as is otherwise we
- 20:57would be running into errors in our own
- 20:59game if you want to add the times three
- 21:00and the auto to your game you guys
- 21:02certainly can and i'm giving you guys
- 21:03sort of the blueprint to do that on your
- 21:04own now we want to create a server
- 21:06script for listening for the
- 21:07communication from the client telling us
- 21:08hey we want to open up this egg so let's
- 21:10go inside of the server script service
- 21:12and create a brand new script and we'll
- 21:14rename this to x the first thing that we
- 21:16want to do is we want to get the
- 21:17replicated storage and we also want to
- 21:19get the workspace as well let's create a
- 21:21variable for the eggs folder just like
- 21:23we did in our handler script so we'll
- 21:24say workspace.x and then we have the
- 21:27folder we also want to get the eggs
- 21:29config which we'll require from the
- 21:31replicatedstorage.configs.exe
- 21:34and then finally we want to get the buy
- 21:36egg remote from there replicate storage
- 21:38dot remotes dot by egg there we go so
- 21:41let's listen for the buy egg remote to
- 21:42be called so we'll say that on server
- 21:44event connect function the first
- 21:46argument is of course going to be a
- 21:48player because whenever a player calls a
- 21:49remote it's always going to pass through
- 21:51the player who called it then we'll get
- 21:52the egg id which is going to be a string
- 21:55and finally we'll get the modifier which
- 21:57is also going to be a string as well you
- 21:59could say modifier or another way to
- 22:00think about it is the action so times
- 22:02three or auto would be the action then
- 22:04we'd say if action
- 22:06equals auto then we would do something
- 22:08right here else if action
- 22:11equals times three then we would do
- 22:13something specific to the times three or
- 22:15if it doesn't equal either of those then
- 22:17we'll just hatch like normal and we'll
- 22:19create a function for hatching in a
- 22:20minute now the first thing we want to do
- 22:21whenever we call this is we want to
- 22:23check if the player can actually hatch
- 22:24the egg so we want to check first of all
- 22:26if the egg actually exists because an
- 22:28exploiter could pass a random string as
- 22:30the egg id and that could cause an error
- 22:32when we're handling this so let's go
- 22:33ahead and create a function called ken
- 22:35hatch which will accept the player as a
- 22:37player and the egg id as a string so
- 22:40first let's get the egg config so we'll
- 22:41say local egg config equals and then
- 22:44we'll index the eggs config with the egg
- 22:47id that were provided from the client
- 22:49and then we'll actually check if the egg
- 22:50config exists so if that config does not
- 22:53exist then it'll equal nil so we'll say
- 22:55if not a config then return n so if
- 22:58we're unable to find the actual config
- 23:00then we'll stop the function right there
- 23:01otherwise if we're able to find the a
- 23:02config then let's actually get the
- 23:04player's balance so the amount of money
- 23:06that they actually have and for us
- 23:08that'll be set to
- 23:11player.leaderstats.coms.value and then
- 23:12we can check if the player has enough
- 23:13money to actually open up the egg so if
- 23:15player balance is less than
- 23:18eggconfig.price then we're just going to
- 23:19return false and end so if the player
- 23:21does not have enough money to open the
- 23:23egg it'll return false and stop the
- 23:24script there otherwise we'll return true
- 23:27so if the egg config is not found
- 23:28because either we made a mistake or
- 23:30there's an explorer try to mess with our
- 23:31system then it'll stop the script right
- 23:33here and return nil we could also return
- 23:35false as well nil or false will work for
- 23:37how we're gonna use it and then we're
- 23:38gonna get the player's balance and we're
- 23:39gonna check if the player has enough
- 23:40money to open it if the player does not
- 23:42have enough money then we're just gonna
- 23:43return false and stop the script there
- 23:44another way to write this which is even
- 23:46cleaner is saying return if the player
- 23:48balance is greater than or equal to so
- 23:50if the player is able to hatch the egg
- 23:52because they either have exactly enough
- 23:54money or they have more money than the
- 23:55egg's price then we'll return the result
- 23:57of that so you can write this either way
- 23:59you want to i'm just showing you guys
- 24:00multiple ways of how to do that then
- 24:01back inside of listing the remote to be
- 24:03fired we're gonna say if not can hatch
- 24:06and we'll pass through the player and
- 24:07the egg id then return end so if this
- 24:10check does not return true then we're
- 24:11just gonna stop the function right there
- 24:13and not run anything else next let's
- 24:15create a function above the can hatch
- 24:16function and we'll actually call that
- 24:18hatch we'll pass through the player and
- 24:20the egg id now each time you open up an
- 24:22egg inside of a simulator you kind of
- 24:24have a little animation that plays which
- 24:25sort of acts as a small cooldown between
- 24:27opening x so in a way it prevents you
- 24:29from opening up like 20 eggs in a sec so
- 24:31what we'll do is we'll actually create a
- 24:33table called hatch cooldown and that'll
- 24:35equal a blank table for now and above
- 24:37here we want to actually create a
- 24:38variable for the specific cooldown and
- 24:40we're just going to say hatch underscore
- 24:42cooldown and we're going to set that to
- 24:43three so we'll have a three second
- 24:44cooldown each time a player successfully
- 24:46opens an egg so when we call this
- 24:47function the first thing that we want to
- 24:48do is we want to check if the player's
- 24:50user id is within the hatch cooldown
- 24:53list and if it is then we're just going
- 24:54to return n because we know that the
- 24:56player is currently on cooldown now
- 24:58otherwise if it's not then we're going
- 24:59to add their user id to the list and
- 25:01we'll just set it to true next we'll get
- 25:03the egg config just like how we did in
- 25:05the can hatch function right here so we
- 25:06can literally just copy and paste that
- 25:08and we also want to get the player's
- 25:09balance as well so we'll just do that
- 25:10again and similar to how we did a check
- 25:12inside of the ken hatch function by
- 25:14checking if the player has enough money
- 25:16to open the egg we'll also take that if
- 25:17statement and change it to what we
- 25:19originally had it so if the player
- 25:20balance is less than the a config.price
- 25:23then just return end so don't do
- 25:25anything below this line but if the
- 25:26player does have enough money to open
- 25:28the egg then what we want to do is we
- 25:29want to subtract the price of the egg
- 25:31from the player's balance so we'll say
- 25:33the player's current money minus equals
- 25:35a config.price and now we actually need
- 25:37to choose the pet from the egg that the
- 25:39player is going to get so another thing
- 25:40that we might want to do to make this a
- 25:42little bit better is we might only want
- 25:43to set the cooldown to be active if the
- 25:46player can purchase the egg so if the
- 25:47player has enough money so once we
- 25:49determine that the player does have
- 25:50enough money to purchase the egg and
- 25:51right before we take the player's money
- 25:52we'll actually set the cooldown right
- 25:54here now let's create a function for
- 25:55determining what pet the player gets
- 25:57from the egg that they just purchased so
- 25:59we'll say local function choose pet and
- 26:01we'll accept an argument called pets
- 26:02which is going to be a table so then
- 26:04when we call this function we're going
- 26:05to say local pet equals choose pet and
- 26:08we'll pass through the egg config.pets
- 26:11and remember the pets is the table right
- 26:13here which holds all the pets inside of
- 26:14it now for the choosepets function we're
- 26:16going to be using the logic posted to
- 26:17the to the developer forums by lord of
- 26:19watermelons so shout out to him for
- 26:21posting the logic to a system which will
- 26:23actually choose a random pet based off
- 26:24different rarities so with that being
- 26:26said what we're going to do is inside of
- 26:27this function we're going to create a
- 26:28new variable called total weight and
- 26:30we're going to set that to zero then
- 26:31we're going to loop through the pets
- 26:33table so in ipairs pets do and we'll add
- 26:36the chance of each pet to the total
- 26:38weight so total weight plus equals
- 26:40pets.chance then outside of that for
- 26:42loop we're going to create another
- 26:44variable called chance and we'll set
- 26:45that to math.random and this is going to
- 26:47spit out a number between 1 and the
- 26:49total weight then we'll create another
- 26:51variable called counter and we're gonna
- 26:52set that to zero and then we're gonna
- 26:54loop through the pets again so we'll say
- 26:55four underscore pet in ipairs pets do
- 26:58and each time we loop through we wanna
- 27:00add the chance of that pet to the
- 27:02counter and then right below that we
- 27:03wanna check if the chance is less than
- 27:05or equal to the counter and if it is
- 27:07then we want to return that pet and
- 27:09that's how we can easily choose each pet
- 27:11based off its rarity so now going back
- 27:12to the hash function we're already
- 27:14calling the choose pet function so then
- 27:15for now we can print you got a dot dot
- 27:18pet dot rarity dot dot space dot dot pet
- 27:22dot id and now that'll print to the
- 27:24console which pet we actually hatch
- 27:25every single time we hatch an egg so
- 27:27back down to when the buy egg event is
- 27:28actually called inside of the l
- 27:30statement we will call the hatch
- 27:31function we'll pass through the player
- 27:33and the egg id and then inside of the
- 27:35handler we're already calling this
- 27:36function so we're gonna go ahead start
- 27:38it up and then we can test this out so
- 27:39we'll come over to the egg we can see
- 27:40it's all displayed very nicely we can
- 27:42click on times one ah i see it made a
- 27:44slight mistake right here inside of our
- 27:45egg server script inside of the choose
- 27:47pet function i try to index pets which
- 27:49is the list of pets and not the
- 27:50individual pet with the dot chance so we
- 27:53need to change it from pets to
- 27:54pet.chance and now we can start it up
- 27:56and test it and it should be good so we
- 27:58come over to the gy we open it up and we
- 27:59can see that we just got a cat now we
- 28:01can try to open it up again but we're
- 28:02actually still on cooldown so we need to
- 28:04actually remove the cooldown from the
- 28:05player as we forgot to implement that
- 28:07back inside of the hatch function what
- 28:08we want to do is we want to say task dot
- 28:10delay and we want it to be delayed by
- 28:12the hash cooldown so it'll wait three
- 28:14seconds and then we want to create an
- 28:16anonymous function and then we'll set
- 28:17the hatchcooldown index the
- 28:19player.userid and we'll set it to nil so
- 28:21that this removes the player from the
- 28:23hatch cooldown list so we can start it
- 28:24up again and test this out let's go
- 28:26ahead and hatch a pet we can see we once
- 28:28again got the common cat we'll hatch it
- 28:29again and we can now see we got the fox
- 28:31we got the dog and if we keep hatching
- 28:33we'll keep seeing that we get different
- 28:35pets after a couple of times of hatching
- 28:37we actually got the turtle and we can
- 28:38just see from this short test right here
- 28:40it does seem to be working with the
- 28:41percentages as we still haven't gotten
- 28:43the pig and we only got the turtle one
- 28:45time out of all the times we've hatched
- 28:46so far now how will we communicate from
- 28:48the server to tell the player which pet
- 28:50that they actually just received well we
- 28:52could use a remote event so we can add a
- 28:53new remote event to the remotes folder
- 28:55and we can rename this to maybe
- 28:56something like pet hatched or egg hashed
- 28:59or something like that and then all we
- 29:00have to do is make a variable for this
- 29:02inside of our script so we can say pet
- 29:04patched we'll rename the variable to pet
- 29:06hats as well and now we can fire client
- 29:08with this to the player and we can pass
- 29:11through the pet table and then from the
- 29:12client we can listen to whenever this
- 29:14remote is fired and now we can remove
- 29:16this print statement and if we want to
- 29:17we can go back to the handler script and
- 29:19we can create a variable for this remote
- 29:21so instead of just by egg we can say pet
- 29:23hatch pet hatch and then we can listen
- 29:25whenever this remote event's fired so on
- 29:27client event connect function pet which
- 29:29will be a table and we can do the print
- 29:31statement that we just did on the server
- 29:33end so we received a dot dot pet dot
- 29:37rarity dot dot space dot dot pet dot id
- 29:40and now we can start this up hatch a pet
- 29:42and we can see that from the client this
- 29:44is now being printed so we received a
- 29:46common doll so from there you could
- 29:47easily implement and add in your own
- 29:49animation or your own special little gui
- 29:51for whatever happens when you receive a
- 29:53pet now the next thing we need to do is
- 29:55add the capability of listening for
- 29:57whenever a player presses either the t e
- 29:59or r key on their keyboard and based off
- 30:01that will perform an action of the ui so
- 30:04for example if they press t we'll do the
- 30:06exact same thing as if they were
- 30:07clicking the times three button if they
- 30:08press e will do the same thing as if
- 30:10they were pressing the times one button
- 30:12and if they press r we'll do the exact
- 30:13same process if they click the auto
- 30:15button now the way we're gonna handle
- 30:16this is by using the user input service
- 30:19so we're gonna get that up here now
- 30:20towards the bottom of the script but
- 30:21above the pet hatch remote we're going
- 30:23to say user input service dot input
- 30:25ended connect function and inside of
- 30:27this function we'll get the input which
- 30:29is an input object and game processed
- 30:31event which is a bullying so the first
- 30:33thing that we want to do is we're going
- 30:34to say if game processed event then
- 30:37return end and when the game process
- 30:38event is true for the most time it's
- 30:40usually if it's sort of like a hotkey
- 30:42that interacts with roblox default
- 30:44systems so for instance if we're
- 30:45listening for the tab key to be fired
- 30:47the game processed event will usually
- 30:49return true because when you press tab
- 30:51the leader stats leaderboard either
- 30:53becomes visible or is hidden now you
- 30:54might need to change this based off your
- 30:56own games you could even delete it it's
- 30:57not too big of a deal but we're going to
- 30:59use this for now and then we also want
- 31:00to check the user input type so if not
- 31:03input dot user input type equals enum
- 31:06dot user input type dot keyboard then
- 31:09return n so if the player is not using a
- 31:11keyboard then we're just gonna stop the
- 31:13function there finally we can start
- 31:14doing things based off of the specific
- 31:16key the player presses so if
- 31:18input.keycode equals
- 31:20enum.keycode.and for the first one we'll
- 31:22be using the t key so if it equals t
- 31:25then then we'll do something else if the
- 31:27keycode equals e then we'll do something
- 31:30and then finally else if the key code
- 31:32equals r then we'll also do something
- 31:34now let's go ahead and create a function
- 31:36above the generate billboard gui and
- 31:38we're going to say local function
- 31:40request
- 31:41hatch and inside of this function we'll
- 31:42accept the egg id as a string and the
- 31:45action as a string as well and now we
- 31:47can copy the logic that we already
- 31:49created inside of each of the specific
- 31:51button clicks and basically paste it
- 31:53into here so first we're going to say if
- 31:55action equals auto then and then we'll
- 31:57paste the logic inside of here and of
- 31:59course instead of firing server with the
- 32:00eggmodel.name we'll fire it with the egg
- 32:03id instead and the auto action as well
- 32:06and then we'll say else if the action
- 32:07equals times one then and then we'll use
- 32:09this logic right here which once again
- 32:11using the egg id instead of the
- 32:13eggmodel.name and then finally you could
- 32:15use an else statement or you can use an
- 32:17else if statement if the action equals
- 32:19times three then we will use this logic
- 32:21down here so there we go now that we've
- 32:24created this function and taken all the
- 32:26logic from the buttons what we then just
- 32:27need to do is we then just need to
- 32:28recall the request hatch function with
- 32:30the correct egg id and the action so
- 32:32we're going to say request hatch egg
- 32:34model dot name like we did previously
- 32:36and then the action so if we click on
- 32:38the auto button that we're going to pass
- 32:39through auto if we click on the times 1
- 32:41button then we're gonna pass through the
- 32:42times one and if we click on the times
- 32:43three button then we're gonna pass
- 32:44through times three now we've created
- 32:46that because we're also gonna be doing
- 32:47the exact same thing down here inside of
- 32:49the kiku so for t that's gonna be times
- 32:51three so we're gonna say request hatch
- 32:53and currently we don't have the egg id
- 32:54but we'll create that in a sec so let's
- 32:56just go ahead and create a variable up
- 32:58here called local egg id and we'll just
- 33:00set that to a blank string for this
- 33:02second so that the request hatch isn't
- 33:03throwing an error and remember t is
- 33:05times three not auto so then we have
- 33:07that set up and now for e that would be
- 33:09times one and for r that is auto so now
- 33:12we need to create a function for getting
- 33:14the id and now the simplest way of doing
- 33:16this would be getting the closest egg to
- 33:17the player and seeing if they're within
- 33:19the range at which the gy can be
- 33:21displayed at so let's create a function
- 33:23right above input ended we'll say local
- 33:25function get closest egg and we won't
- 33:27accept any variables so inside of this
- 33:29function we're going to create a
- 33:30variable called closest and we're going
- 33:32to set this to a table and kind of input
- 33:34fake data currently so we're going to
- 33:35say egg equals nil and distance equals
- 33:409999 and we'll see why we're doing that
- 33:42in a second then what we're gonna do is
- 33:44we're gonna loop through each of the
- 33:45eggs inside of our eggs folder so four
- 33:48underscore egg in eye pairs eggs folder
- 33:51get children do and then we need to get
- 33:54the distance so local distance between
- 33:57equals player dot character dot primary
- 34:00part or you could even get the humanoid
- 34:02root part but we'll just say primary
- 34:03part so player.character.primarypart
- 34:06so basically the position of the player
- 34:08minus the egg dot position that
- 34:10magnitude and now we have the distance
- 34:12between the two parts so then we want to
- 34:13check if the distance between them is
- 34:15even close enough to be displayed so if
- 34:17we look inside of the template and we
- 34:19look at the max distance it's 17. so we
- 34:21can say if display distance is greater
- 34:24than 17 then continue end so with most
- 34:27likely the gy wouldn't be open because
- 34:29the distance is too far then we'll go to
- 34:31the next egg and check that distance now
- 34:33if the distance between is small enough
- 34:34meaning that they're close enough for
- 34:36the gy to be open then we want to check
- 34:37if closest dot distance is greater than
- 34:40the distance between so basically if the
- 34:42last closest egg is actually further
- 34:44away than the current distance between
- 34:46then we're going to set closest to a new
- 34:48table with the egg equaling the egg dot
- 34:50name and the distance to distance
- 34:52between and that's pretty much it for
- 34:54the loop so it's going to get the
- 34:55distance between the player and each of
- 34:57the eggs is going to check if the
- 34:58distance between the player and the egg
- 35:00is greater than 17 which is the max
- 35:02distance that the gy can even be
- 35:04displayed at then it's gonna check the
- 35:05next egg and do the same thing but if
- 35:07it's possible for the g wire to be open
- 35:08because the distance between is smaller
- 35:10than 17 it's then gonna check the last
- 35:12closest distance and it's gonna compare
- 35:14that to the current distance between the
- 35:16player and the current egg inside of
- 35:17this loop and if the previous distance
- 35:19is greater than the current distance
- 35:20then we're gonna update the closest
- 35:22table with the new closest egg to the
- 35:24player so then finally what we're gonna
- 35:25say at the bottom after the for loop is
- 35:27we're gonna say return closest dot egg
- 35:29and then back inside of when we listen
- 35:31to the input ended we're going to call
- 35:33the get closes egg function and then
- 35:34we'll say if not egg id then return end
- 35:39so if the egg id is nil because the
- 35:41player was not in the range of any of
- 35:43the eggs then we're just not gonna do
- 35:44anything otherwise if the player is
- 35:46within the range then we're going to
- 35:48fire the request hatch function which
- 35:49will run one of the actions so now we
- 35:51can start the game up again and test
- 35:52this out so if we go over to the gui and
- 35:54we click the button we can see that we
- 35:56actually are hatching a pet and now if
- 35:58we click the e key we can also see that
- 35:59we're hashing a pet as well and we just
- 36:01got the cat once again and we're
- 36:02actually having weird luck we're getting
- 36:04we just got the cat three times in a row
- 36:05but now we see we also hatch the fox and
- 36:07that's working exactly as it should so
- 36:09now the final thing that we're gonna do
- 36:10is create another egg config so that we
- 36:12can see how we can easily call the
- 36:13generate billboard for multiple eggs so
- 36:15if we look inside of our eggs folder we
- 36:16have the basic and the rare egg we'll
- 36:18duplicate this basic egg config by
- 36:19copying and pasting it just like that
- 36:21and now we'll rename this from basic egg
- 36:23to rare underscore egg we'll change the
- 36:25price from 2000 to 5000 and now let's
- 36:27say we want the dog to be rare we don't
- 36:30want there to be any bunny or cat and
- 36:32we'll have the fox as rare as well and i
- 36:35guess that's it we'll just have the dog
- 36:37and the fox both being rare and the
- 36:39chances of getting these will be a five
- 36:41percent and a two point five percent and
- 36:43actually i messed up with the price we
- 36:44want it to be five thousand not fifty
- 36:46two thousand okay so there we go we now
- 36:47have our quick little config set up so
- 36:49right where we call the generate
- 36:50billboard gui function we're gonna loop
- 36:52through the eggs config so we're gonna
- 36:53say for egg name comma egg config we
- 36:57could say name and config but this makes
- 36:59it a little bit less confusing in pairs
- 37:01egg config do generate billboard gy eggs
- 37:05folder and we'll index that with the egg
- 37:07name comma egg config and now we can
- 37:10remove the generate billboard function
- 37:11because now like i said it's going to
- 37:13loop through each of the eggs that we
- 37:14have set up in our config and that will
- 37:16call the function for each of those eggs
- 37:17the other thing that we want to do is we
- 37:18probably want to move the eggs a little
- 37:20bit further away from each other so
- 37:21we'll move this rare egg like about over
- 37:23here and then we can start our game and
- 37:25test this out so now we can see we can
- 37:26walk over to this egg right here and we
- 37:28have the basic egg being displayed with
- 37:30all the pets inside of it and we can
- 37:31hatch it and we see we get the common
- 37:33bunny but we can also walk over to this
- 37:34egg over here as well and it's displayed
- 37:36a little bit further down because
- 37:37remember we have the attachments set up
- 37:39differently between the two but anyway
- 37:41we can now see the contents of this
- 37:42being generated so the rare dog and the
- 37:44rare fox with their chances of hatching
- 37:46so 5 and 2.5 and then we can press or
- 37:49click on e and we can now see we receive
- 37:51a rare dog so these are both working
- 37:53exactly as they should be okay so we've
- 37:55done a lot in this episode anyways
- 37:57ladies and gentlemen with that all being
- 37:58said i hope this guide did help you guys
- 38:00out it was a lot of work and a lot of
- 38:01effort if it did make sure you guys
- 38:02smash the like button also hit the
- 38:04subscribe button and turn suppose
- 38:05notifications on if you want to get
- 38:06notified when i upload more roblox
- 38:07development content of course i do have
- 38:09patreon if you guys like this for me and
- 38:10gain access to all the scripts and the
- 38:12game file i made during this episode
- 38:13there's a link down below description
- 38:14and you guys can go and check that out
- 38:15with that being said i hope that you
- 38:16guys have a great day and i'll see you
- 38:18guys in the next episode
About this transcript
This page contains the full transcript of Scripting the Pet Egg Gui! Roblox Studio Simulator Guide Episode 25 by MonzterDEV, generated from the public captions YouTube serves with the video. The transcript has 9,806 words across 1,294 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.