Transcript for:
Creating a Game Like Super Power Training Simulator

Hey guys, TSL here back with a brand new video. Today I'm excited to announce that we will be starting the remastered version of our How to Make a Game Like Super Power Training Simulator series. In this series, I aim to make this game with the best possible practices as well as the most functional, clean, and reusable code that will work consistently and for a long time in the future. Now to start off with today's video, we will of course be making some of our tools. So to do that, we're going to go ahead and insert three tools into our starter pack. We're going to have three of them and one of them will be called a punch I guess. One will be push up and the other one will be the psychic. For all three of these tools there is one setting that you must disable and that is the requires handle. If you have this requires handle checked and you don't have a part called handle in it these tools will not work Next thing I want to mention is that in replicated storage I just have a folder called modules and it has the big num module in it. I'll have a link to this in the description but that's all that's in there and we're going to be using that to make huge numbers if you want to go if you want to learn more about bignum just click on the video in the top right corner anyways to continue we will insert some we'll insert a script into server script service this will be called our remote events handler so So we'll go local rs is equal to game.com.getService.replicatedStorage. And then we'll have local remotes is equal to rs.remotes. Local server remotes is equal to rs.server. or not rs, remotes.server, and then local r events is going to be equal to serverRemotes.events, and yeah, that's all we need for those. So then in our replicated storage, let's make these folders not a local script. We want a folder, and this folder will be called remotes. There will be another folder inside of this called server. and then a folder in here that will be events and the other folder in here will be called functions so this will be like for remote events and this one for remote functions and then we're going to duplicate this server and call it client for client remotes and then in server storage we want a folder and this one is going to be called modules modules And we are going to have a module script that stores all of our helper functions that we might need in multiple script. So here are our helper functions, and we'll call this helpers and return helpers. Okay, so then over here, let's also grab local ss equal to game.con.getService. server storage and something that we will need or first let's add some comments so this will be remotes this will be modules and this will be SS or local helpers is equal to ss dot modules or local modules server modules is equal to ss dot modules and local helpers is equal to require server modules or server modules dot helper functions you Then here we can actually begin with our remotes, our remote handlers. So have a local remote handlers, and this is going to be equal to just a table. And basically, how this is going to work is we're going to have the name of the remote event here. So we're going to have the name of the remote event here. So if I have punch, for example. Punch and make that equal to a function which of course will have a player since it would be a remote event Then basically if I have a remote in the server events remote event And it's called punch. Then basically it's going to run this event since it has the corresponding name. Just make sure the names are exactly the same. Before we continue in here, or actually first let's just hook up everything. So hook up the events. We'll say for underscore comma remote in server remotes or our events actually. Our events do. So we get every remote in our remote events and we want to say remote. dot on server event colon connect not connection colon connect and we want to connect this to our remote handlers at our remote dot name So this just does what I was telling you about before for every one of our events in here. So now before we continue with this script let's make some of our helper functions. So obviously we need to go into our helper functions module and we're going to need some stuff because we will need big num in here so we are going to say local rs is gamecoin get service replicated storage and local client modules is equal to rs dot modules and local big num is equal to rs dot or not rs client modules dot big num and we need to require client modules dot big num Okay, now let's start with a couple of our helper functions. So these first couple of functions will be helpers to our helpers, basically. So we're going to have a function helpers.check debounce time, and it's going to have the debounce, and it's going to have the cooldown length. So we want to say return debounce is less than os.time minus cooldown. If it is, then our cooldown is complete and we can use whatever was on cooldown once again. Next, we'll have some functions to just make using bignum a little bit easier. So we'll have helpers.bignumadd and we'll have stat and amount. We'll have local B num is equal to big num dot new and This will be stat dot value and our local result is going to be equal to big num dot empty dot add and this will be our B num and our amount So then what we should do or what we can do is just say stat.value is going to be equal to bignum.empty.toString and our res. Then this is basically going to be the same thing for our bignum sub except here we're going to say sub instead of add. all right so that is it for our helpers to our helpers for now and now let's get into some of our um like main core stuff like the punch and the push-up so we'll have we'll call this like stats stat helpers first thing we'll have is a local function or a function called helpers dot train this is going to be our main function that will well train everything or basically add to our stats. But before we do that, we want to... Actually, never mind. We don't want to do anything before we do that. So what we're going to do is in this function, we will take in a player, and we will take in a stat name. Our local character is going to be equal to player.character. And we're not going to wait for anything because we don't want them to be able to train while they're dead. And then just wait for them to respawn. So basically that's that part and if we don't have a character then we just want to exit out of this function because if we're dead we don't want to let them add to their stats. So get a local stat is equal to player.physicalStats. colon find first child stat name our multi-name or actually we're not going to be doing multipliers in today's video that will be next time so we're going to skip all that for now And I guess we're just going to go with our helpers.bignumadd and we'll add to our stat and we'll just add 1 since we don't have multipliers yet. So that should just be training enough. And we will have one other thing for our endurance tool. So we'll say if stat name is equal to endurance, then what we want to do is say helpers.calculate health. And we'll pass in the player and our stat. Then right above this, we'll have our function helpers.calculateHealth. And this will take in a player and a stat. stat, or endurance I guess we can call it, since this should be the only thing firing this, it will say local character is equal to player.character, and if our character does not exist, then return end, and our local humanoid will be equal to character.humanoid, and our local endurance is going to be equal to endurance.value. Then we can say humanoid.maxHealth is going to be equal to our helpers.bignumAdd, and we will add, well actually, We will add our bignum.mt.2string version of a bignum.mt.multiply, our endurance by 10, and then, let's see, this, then over here, and we'll add 100 to that. So like if we have zero endurance, we're going to have only 100 health because it'll be 0 times 10 plus 100. If we have 1, it'll be 10 times 1 plus 100 and so on. So that should be it for our calculate health function. And hopefully everything should be working now. But obviously before we can do that, we actually need a leader stat script. So let's go ahead and do that quickly. In server script service, insert a script. we can call this leader stats and here we'll have a local players equals game call and get service players we'll have a local on player added local function on player added player and down here we'll have our connections And this will be players.playerAdded, colon connect on playerAdded. Then here what we'll do is just have our local physical stats is equal to instance.new folder and our physical stats. dot name is going to be equal to physical stats and physical stats dot parent is going to be equal to our player then in here we're going to have our strength endurance and psychic as well as some other stuff that we'll add later so say local strength is equal to instance dot new string value since we will be using bignum you Strength.name is equal to strength. And strength.value is equal to 0. And strength. dot parent is equal to physical stats. And one thing we should do is put this all the way at the end, and then we can copy this, paste, and paste, and then change this one to endurance, since they are all going to be the same, and then this one to psychic. Okay, so this should give us our stats inside of our, well, you know, our player. It won't show in the leader stats since we are not using any leader stats. The leader stats doesn't show the stats, but it will show other stuff, but we will make that later on. Alright, now let's start on our punch remote event. So we'll say if our debounce, so actually one thing that we'll need is some more variables. And this will have our local debounce is equal to that, and this will be debounces. It's going to be a table of all the current active debounces. So say if debounces and our player.userId. Let's make this capital and this capital. Player.userid. Real quickly, guys, before we continue, if you'd please leave a like, comment, and subscribe to the channel, it would really help me out a ton. Now we'll right back into it. Then we'll get our local player, or PLR, deb's for debounces is equal to debounces and our player.userid. We'll say if in our player debounces we find a punch debounce, then we'll get the debounce time equals to the player's debounce punch. And we will also check, and then we're going to say if our helpers.checkDebounceTime for our debounce time, and the cooldown for this will be 0.75. Then, and if we are off cooldown, so if this is true, then we are off cooldown. Because remember in our helpers function. If our debounce time is less than os.time minus cooldown, then that means we are off cooldown, and if we are off cooldown, this returns true. So then we can just say plr is debounce, punch is going to be equal to os.time, so we will start a new debounce from the current time, and then we will also train. R for our player, and we will train the strength stat. This is also where we like to detect for damage, but that once again comes in a later video. So if there is no debounce for the punch, then what we want to do is essentially the same thing as we did here. And. And then if there is no debounce at all, if the current player does not have any debounces active, then we will say our debounces at player.userId is going to be equal to punch. At os.time, so we're going to add a punch debounce at the current time, just like we were doing up here. And then we will, once again, train. So this should be how every one of our stats look like, or how every one of our stat adding things look like. So if we just essentially copy and paste this. And then if we, let's just zoom back in, we'll say push up and we'll replace everywhere it says punch with push up, push up, and then where it says strength with endurance. Push up, endurance, push up, and endurance. Here we'll say, I guess, meditate. And we'll replace punch with meditate everywhere. And then strength with psychic. Psychic. meditate and psychic so now if all is working well actually first we have to add our remote events for all of them so here we'll have meditate or this one will be push up And then this one will be meditate. Make sure it's the exact same spelling once again. And hopefully everything should work. So if we go ahead and save to Roblox as, I will create a new game. And we will say YT SPTS tutorial remastered. I'll turn Team Create off. and i will save we'll close this now and go ahead and click play okay so we do have one error in here it says attempt to iterate over an instance value well obviously if we go back here we need to do our events go and get children Alright, so everything should be working now, hopefully after we fix that error, but we don't have any way to really test it right now. So let's just make a quick little local script in our punch tool and we'll call it train. And we will say local RS is equal to game. Go and get service replicated storage local our events. localRemotes is equal to rs.remotes, localServerRemotes is equal to remotes.server, and localSevents is equal to serverRemotes.events. Then we'll say local function activated. and script.parent.activated and here we'll say, well actually up here we'll also need our local players is equal to game.getServicePlayers and I like to have that all the way at the top And then here we can add a space and here we will down here add a local player equal to players dot local player and Here what we will do is s events Dot punch colon Fire server and I don't think we have to pass anything so I actually think we didn't need to get the players but let's just check it out. So if we go to players, Domos37, physical stats, right now our strength is at 0. If we punch, it is still at 0 and it doesn't seem like anything is firing or we don't have any errors in our console. Heading over to our remote events handler, if we go to our punch, let's just print out that punch. Okay, so if we click with our tool, okay, you see it is saying punch. We're just not getting anything in our strength stat. So let's try to see where so let's try to see where we went wrong We'll add a so actually for the first punch. We should be over here, right? We should be right here So let's print Add strength or actually will print first timer And then in our helper functions, we'll go down to our train. Oh, here it is. We forgot to add a not. That's our problem. Everything should work now. Alright, so we should be having some amount of strength, which we have 4. And you see I'm spam clicking, but it's not registering every click because we have the debounce enabled. Alright, so everything was working perfectly fine. It's just over here we forgot to add a knot because we originally had it like this. So if we found a character, then we would exit out the function, but what we want to do is when we don't find a character, we want to exit out of the function. So we can go back here and we can remove all of these prints, this and that. and um i guess if we want to we can copy this train script and push paste it into our pushups and psyker then go just go down here and we can say as events this one is in the push up so we'll say push up and we can remove the player and local players thing because we don't need that we can remove that from here as well And then we can go into this one and this is going to also get this removed, this removed, and this one meditate. And now all of them should be working. Go in and press. play and let's take a look at our stats before and after so right now we have zero endurance zero psychic and zero strength start off with a string you see we're clicking and we're getting some strength for our push-up let's click on our endurance real quick we have zero we're clicking and we are getting endurance we do have some little errors or warnings i will take a look at that in a second but for our psychic right now we have zero and when we click we are getting stuff obviously that's not how the psychic tool works but we'll fix that in the next video right now let's just take a look at what these errors are saying it happened when we started with these endurance i'm pretty sure Okay, so it has something to do with the helpers, but I'm pretty sure it was doing that with Oh, never mind. Okay. So yeah, it was only the endurance Okay, so basically attempt to index a string with value Attempt to index string with value stat dot value and then okay so big num add okay so this one we're just going to have to use the regular built-in bignum.mt.add since we're doing the two string anyways it shouldn't be any different so now if we go ahead and test this out hopefully we shouldn't be getting those errors anymore we push up and we're not getting any more errors let's just make sure we were still getting our endurance though and if we check we are Alright nice, as you see everything is working and it's already looking a lot cleaner than the previous version of this game. If you guys do enjoy this, please remember to leave a like and comment what you guys want to see in the future. And other than that guys, I hope to see you back here in the next one.