Obby Ideas In Roblox Studio #7: Hidden Paths

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
[Music] if you'd like to learn how to make Hidden PS in your Obby keep watching and I'll show you exactly how to do it welcome to Roblox Snippets all right in this video we are going to look at creating a hidden path that we can insert into our Obby and if you haven't watched my videos before uh I usually do the example here and then at the end I will show you how to add this new Obby or obstacle into a main game Lobby and Link them all together so to begin with we will create a couple of items um for us to use uh in this example so if you come up to home and then to part we'll just create a standard part for a start and we'll call this one path okay I'll just make that all lower coas path part and it's just going to serve uh as it as suggested you're just going to run along on it so I'll leave it gray and we will make it a Pebble sort of shape and we can just scale this uh to be big enough to run on so let's just make it out like this a little bit and you want to come down and anchor this part it's not going to do anything as such uh except for us to run on it and we might lift it up off of the base plot and I think um just for now we'll we'll move our spawn point as well sort of up near it ready for us to run or jump onto it all right so just uplo that so that it's sitting up off the ground right now what's going to happen uh there's two parts to to our coding here I've made it a bit of a challenge for the players that the hidden path will only show up if uh the player has not died yet in the game so we're going to simulate that by creating a script in the base plate so to make the base plate a bit more scary we'll make it lava so you can select base po come down and we'll make it uh red and we'll change the material to be uh cracked lava all right so it looks a bit ominous and we're going to add a script into the base plot so go ahead and click on plus next to base plate and add a script and we'll call this our Kill player script now we're not going to kill the player um in case you're distressed we're going to simulate killing the player uh so that we can just do the example all right so in the script we'll create a variable for the Bas plate so base equals script. parent and we'll create a DB all right a variable which is debounce this is to control our script and now we'll create a touched event so base. touched and we will connect a function to this and pass in in the brackets the parameter of hit which will be the part of the player that is hitting the base plate so it could be their leg or their arm Etc from this we can get our player so we can say local player equals game. players and we'll say get player from character now as I said this is a part of the character so if it's the character's foot its parent will be the character itself so we can simply put in here hit. parent and that will get us our player now just below this we'll make a conditional statement so if player and DB then so if both of those are true then we can say DB equals false oh this helper um that you could do what it says here but that's not what we're going to do and down towards the end of the script we're going to say task. weit of say a second and then we'll set DB back to true so this effectively lets us run whatever's inside here every second okay now we're only going to run this once because once we've killed the player that's all we really need to do all right and we're going to do this with an attribute so we're not quite finished this script yet but if we come back to our workspace and I'll just bring up the Explorer and properties window we'll come down to our server script service and click on plus and we're going to add a main script in here so main script so this runs first for all players when they enter the game and we're simply going to add in here game. players and player added and connect a fun to this and pass in whoever the player is that's joining the game and we're only going to add one line inside of here uh at the moment to to make this work and we're going to create an attribute for the player now if you haven't used attributes they are like variables but we can attach them to um well the player or anything just about and they you'll find that they are much quicker as well so the way we do it is we say player so whichever player it is I call set attribute so this is creating the attribute and we're going to call it is alive so you can spell this all lowercase if you want but however you spell it this is how we need to refer to it in the future so just pay attention to how you set it up and then move outside the inverted commas and put a comma and now we're going to put the value that we want to make this attribute and in this case we're going to make it true so the player is alive okay now if if you want to see how that uh looks or where you find this if you come up and click on play and you can just follow along if you like um or do it yourself but if we come up to players while the game's running and I click on my character name if you come down into the properties and scroll right down to the bottom you'll see attributes is live has been added down here with a checkbox so it's like a Boolean all right checked is true unchecked is false all right so that's where to find it so we can stop that there and come back to our Kill player script and inside of here we're now going to check to see if that variable is um if the player is alive and because they're landing on the lava if they are alive we're going to set it to false and give them a message so we do that by saying if player and this time because we've already got the attribute we'll say get attribute and a set of inverted commas is alive all right make sure the spelling is correct then outside of here then so this line will effectively um return the value that is attached to this so if this is true which it will be when we start this code in here will run and if that is the case we're going to say player set attribute is alive and mo outside and we're going to change it to false and when we do that we'll give a special message in the output window by saying warn which will come up in an orange print statement and we'll give them the message you died okay and so no matter how many times they fall off then if they are already dead so is alive is false they'll only get this message once and we won't reset is alive um for the rest of the time they play okay so you'll see how this all works together very shortly but for now that's all we need to have in this script so if you've got that you can close that script and if you want to give it a run uh by all means come up to view and click on output window so you've got a message down here and we can run all right so I'm in the game and now if I run onto the lava you'll see down the bottom you died all right and no matter how many times I run around now it'll only say it once because I'm already dead okay and if I jump up here nothing's going to happen right but that's what you want this message down here so I'll stop that there all right uh for the the last part of this first section we just need to create a couple of models so up in our workspace uh we will now create a another part so come up to home and then apart and we'll call this um a box and this this is just going to be dummy boxes because in the main script I've got actual boxes that I've made but to make it look a bit like a box we'll make it brown and we'll come down to make it uh wood planks and whoops I changed that by scrolling on it um let's see wood planks there we go and now let's uh come back up to the top uh or down to its size and let's make them four by 4x4 so we've got a box shape and down here we can turn off can Collide so the players can run through them but we'll turn on anchored so that they stay wherever we put them and if you just move off to the side and I'll hit F on my keyboard we're going to make a little pile of these boxes so because we made them four um we did make them four didn't we yes four we can come up to model up the top here and click on move and we're going to move or duplicate it and move it over so it sits next to it so if we put in here four studs and then if I click on the box and right click and duplicate I can now just move this one across like this and you can repeat that a couple of times so move it in front and right click and duplicate move it over here and the last one will'll duplicate and move it up and now we want it to sit in the middle of these so if you change this to be half of whatever the size of the box is and move it one click to the the right or left and then into the middle we have a nice neat pile of boxes so click on the first box and then come down and holding down shift click on the last one to select them all then right click and come up group as model and we'll change the name of this model to be Box model and now we can move that whole box sort of out to the side out here like this now the idea of this is because we're having a hidden path and if you've played Crash Bandicoot you'll probably see where I'm going with this sometimes you can see objects that you should be able to get but you can't work out how to get there and that's a little bit uh what we're going to do here so these boxes will be sitting out here that the player wants to to collect but they need to find a switch over here which will create in the moment to create a PID path to come out into the boxes so let's make our switch down so back into the workspace we'll come up to home and click on part once again and we'll call this our trigger part we'll make it um down in its size we'll make it 4X 4X 4 and you can uh make any color you like I might just make mine a yellow one and just leave it as plastic and I'll just turn that off so I can move this up so it's sitting on our path all right I did put um you can put decals or whatever you like in there but we'll just make it like this then come down to can Collide and turn that off turn on anchored and it will stay where it is here for the player to run into all right before we uh make the script for our trigger part here we will create our hidden path that will let our players get out to our pile of boxes so come up to the workspace and we will come over to home and we'll create a path now you can make this I'll leave it the same as what the path is here uh and we will make this Pebble and we'll make this like a tile uh and we're going to reveal each tile out to the path until the player can run onto um the path and get out there to get the boxes so we call this part our hidden uh part or path maybe would be a better term so path and let's make this um we'll change the size down here to be 5 by 1 by five and that will be we could probably make it bigger than that if you like so let's say we go 8 by one by 8 and that will be quite big and move it over so that it's lined up with our trigger so just up and sort of level with your path um let's move in a little bit come down and that's that's pretty good about there I think all right so we've got it lined up with our path here at the moment so the next thing we want to do is come down to can Collide needs to be on so that they can run on it and also anchored will need to be on also we will make this invisible to start with but until we've built our path we'll we'll just leave it visible like this now we want this to uh appear in order out to our pile of boxes out here so for that reason we'll take our first part that we've built here and we'll right click and we will group it as a model and we can change the name of this to Hidden path model and now we can duplicate and move these out uh to our box and that way because we're doing it inside the model then they should appear in order all right and if it doesn't then I'll show you how to fix that now as I said before if you come up to model and click on move and we want to be half of whatever the width of this is and we made uh our our path down here eight all right so we want to change this to be eight so not half sorry um we want it to be eight so that when we duplicate it we click on it right click and duplicate and then we can snap it straight out in front of us and you can continue to do this now obviously in your game or your project your path can go left right um even up or down if you're like uh doesn't really matter um but this is the process that you should go through in order to get it to appear correctly all right so continue to duplicate these and move them out to our box out here so duplicate and we'll move out here now when we get to here let's reposition our our Box model sort of on top of the the path like so and maybe move it over um where are we Sor right move it over a little bit there we go and it's sitting on the end of our hidden path okay so it's quite a simple path uh like I said you could make it go around corners and do all sorts of things if you like so now that we have each of these in here let's click on the first one in our model and then come down hold down shift and click on the last one and while they're all blue like this if you come down into the properties and change this to be one then they will all disappear all right now the other thing before you click off it is we don't want them to accidentally discover that they can run on this so if we come down to can Collide let's turn that off as well and that way the players can't accidentally run onto this and discover that they can run out here all right so we're all set up now to add the last bit of code that will uh let us reveal the path if the player hasn't died and if they do die by falling on the lava this box will simply disappear and the path will not show up so to do that we'll come back down and find our trigger part and add a script to it and we'll change the the name of our script to be uh just trigger script and then we can come into our script and write the code so get rid of hello world so the first thing we want to to get is create a variable that will represent all of these parts in here so that we can run some code that will reveal them turn on can Collide but we want to do it in order from top to bottom all right so now as I said they should appear in order as we we put them down here but uh because we didn't put any numbers in here we'll just have to watch uh when we when we run the code code so let's create a variable called hidden path and it will be equal to workspace do hidden path model and then we want to put a colon and get children all right so it will look inside of this model gather all of these parts uh and put them over here as a table for us to work with in our code and I'll just get rid of this so you can see so right below this we'll create a variable now for the trigger itself so the part that the player is going to touch and that will be script. parent and we'll create our um our touched function first so trigger do touched so when the player touches this part we want to connect a function to it and once again pass in the hit which is the part of the character whoops there we go and we'll get our player again the same way we did before so game. players get player from character with hit. parent in here and now we'll create a conditional statement using IF player and all right we'll use the attribute so player get the attribute of is live so make sure you pay attention to spelling and then outside then so if we do actually have a player here and that player is alive then we can run the code inside here to reveal the boxes all right now when we reveal the boxes uh it's going to take a little bit of time so we're not going to reveal them all at once we want one to appear and then the next one so for that reason we'll create a function up here to do that for us so outside of our trigger just drop a couple of lines here and we'll create a function so local function show path and hit enter and then inside of the function here all right it's this helper thing has come on here um we're going to change the transparency and can Collide uh with a slight delay between each one and we'll use a for Loop to do that so we'll put in here for I = 1 and a comma and then hashtag hidden path do now the hashtag will count all of the parts in here so if you change how many parts are in here the code won't break it will simply count however many um bits of path that we have inside of our table and once we do that for each of them as it Cycles through we want to look in the table up here right and we put a set of square brackets and inside here it's looking for an index number which we're going to use I so we put I in here so it'll be i1 2 3 Etc till it gets up to the end and then for that particular part we're going to change its transparency and we're going to set it to be zero all right which will reveal it and then we can say hidden path by can Collide will equal true so if we ran this at now because code runs so quickly it would just simply you touch the part and all the parts would just appear as one all right which is not what we want to happen so we're going to put a slight delay here at the end uh task. we of say1 second between each one and it run now because this is running around and around if we look back down our script we want to do other things after we've revealed this so we really need to wait for this function to finish before we carry on down here and we do that uh we're going to add just at the end of the the function line up here so outside the four return and we'll say true okay now what that means is this will run around um for however long it takes and when that for Loop is finished it will return a value of true to whatever called the function and we're going to do that just down below here so inside of our if player and get attribute we'll put in a loop here that will just stand still and wait for this to return true and we do that by saying repeat task. wait so it's just going to wait over and over until show path all right now basically what that will do is it'll start here and it'll go wait it'll check to see if show path is true which it it won't it'll just um return back nothing until it gets to here and when it is true it's looking for the uh the value here then it will move on to the next line which in in which case we're simply going to destroy the trigger part that um will make it disappear so we put trigger and Destroy and that will get rid of the part now this is dependent if the player is alive so now we'll write a piece of code that um when uh that if the player is dead then we're simply going to give them a message and destroy the part anyway so just below this type else if so if we still have a player and this time we're going to say and not player get attribute is alive then now when you put the word not uh in front of uh a variable it's saying it's looking for true but the not saying we're looking for false so this is saying do we have a player and is the player Dead all right so that's what that means it's not true which is false so hopefully that makes sense and if that is the case we want to print a message and say no path for you and right below this we say trigger destroy and we will get rid of that so I'll just make this a bit smaller so you can see everything going on here uh just a little bit small so that's the whole script there and we are ready to give this a test now so before you test just come up and give your project a save and come up to view if you don't have your windows open and we'll open up our output window down the bottom to check if we have any errors When We Run the game and then we can come up and click on play all right I'm in the game okay and let's check out our dead status for um for a start let's run off and die intentionally and you'll see down here you died all right so I can come over here and jump back up onto the platform and now when I run up to the trigger it disappeared and we got no path for you so the player missed out on getting these bonus boxes out here right so to check again we'll stop the game and run it a second time so that part is working for us and now we've loaded in again the player hasn't died yet and if I run and jump onto the path and then run over to our trigger you'll see that our parts all showed up out to our boxes and I could run out here and collect the boxes if they weren't dummy boxes all right so hopefully yours is all working like that now if that's enough for you and you want to take that away and put it in your own project uh good luck however if you want to stick around and see how I add this into the main game um Obby that I'm creating stick around and I'll show you how to do that next right if you've stuck around uh this won't take very long we're going to take what we have built here and move it into our main game Obby project now if you have been following along from the first video and creating it along with me you can follow along with me now uh otherwise you can just watch and see sometimes we come up with some problems that um that you wouldn't otherwise expect but uh this one should be pretty straightforward so all we're going to do with this is to take uh our path that we built here so our hidden path model and right click and come down to save to file and on your um computer somewhere create a folder like this resources where you can find it again and I've called mine hidden path model I've already done it it should be an rbxm file and then click on Save now I'll just replace that one the only other part that we need is our trigger part down here so do the same thing with this right click and come down to save to file and call it trigger part into the same folder rbxm file and click on Save I'll just replace mine now we don't need our Box model because we've got that in here and the kill script in the the base down here that we created uh I've already got that in there as well the only other thing that we will need to look at is in the main script of creating this variable but we'll do that shortly so I'll switch over to the main game Obby now and we will add it in all right I've opened up main game Obby in here and we've got lots of obstacles going on here um just a quick overview we have just a standard path a path that moves backwards and forwards our animated boxes that uh move Etc and we have these lighter colors are checkpoints and then we have these stairs that disappear uh when you run up them and spinning platforms all right so we've got a lot of things going on now we're going to add in our um our hidden path and you could add this in anywhere if you really wanted to but to get into the game click on workspace then right click and come down to insert from file and locate the folder where you had your your model and let's insert our hidden path model into the workspace it's currently all invisible but uh we'll fix that in a moment and do the same thing with the trigger part so right click insert from file and insert our trigger part all right so we have this in here let's um change our hidden path model here uh click on the first part hold down shift and click the last part and then down in its properties let's change its transparency to say 0.5 so we can just see it and that way we can position it correctly now you can like I said you can put this anywhere you like so I'll take my trigger part here and we will move it over and I might make it uh appear up here for now now this may change in the main game a bit later but just to show you how it goes in and we're going to place it just on top of this part here so it's it's there when the play gets up to this checkpoint and then we'll take our hidden path model and we'll raise it up and bring it over as well and then to spin it around if you click on command or control and hit R you can spin the model around and let's just position it correctly over here so we'll move this up to the top and maybe over this way a little bit right now the player really needs a reason to go out to the end here so what we'll do is take one of our boxes which is in the folder up here and we'll simply duplicate uh a box so right click and duplicate and then we'll move it up and across over to near the end of our our path and let's just move up here now I won't bother making a pile of boxes like I did before cuz that's just repetitive and you don't need to watch me do that but you by all means you can put more time and effort into the details of your your game and I can't can't quite get him to sit up on top of that platform there just at the moment I'll just bring him up there we go that's right all right so we'll just put one box there and we're up to this part here right so this checkpoint here if we come to work out where where we are checkpoint one is where we start the game down here checkpoint two is this one three is this one and we should find that checkpoint four is this one up here so to test this we might um come up to uh come into our main script because we need to add something into our main script as well so open up our main script and we have all this going on now the first thing we'll do is add another attribute we've already got one here for level complete let's now put it in attribute player whoops oh set attribute is a and we'll set that to be true okay now that's creating the attribute now if you remember um we we created the the part uh in our base plate to kill our player so let's have a look at that script now as well so open up your base plate script and at the moment it's just dealing with the checkpoints to to see what's going on now we will simply put in a conditional statement in here once we got the player so if we drop into here I'll just make this a bit bigger and we'll say if um not player get attribute of is alive and then outside here we're simply going to make the player Dead all right so we will say player um set attribute is alive and we'll set that to false because remember they are hitting the lava and even though they don't die and you know get moved back to a checkpoint um the condition of our our trigger box here is that they haven't died by the time they get to this point all right so which means uh they have to be alive and not have fallen off until they get to here for this to work and that should be all that we need to do in here um um to get that to work uh sorry that's not right there this should be if player is alive then we want to make them dead so sorry about that but that should um should be correct now and then it will run the rest of this code down here now the last thing we need to do is to come up to our hidden path model and set all of our our parts in here so select them all and the transparency we want to set to one so that is invisible and now we have this mystery box out here now if we want to start from this checkpoint here checkpoint 4 in our main script we can cheat by coming in and changing the actually that's not going to work because I was going to say if we fall on the lava we'll go to checkpoint 4 however we'll then be dead and it won't work anyway but um let's just play it and we'll uh test both at this stage so I'll open up the output window and and let's play the game all right I have uh an error message that's come up and I'll just um I'll leave this in here because like I said things pop up sometimes because we've got data stores in here um even though I have it turned off at the moment because the game's not published it's causing an error and you can simply come up here and comment that line out just at the moment and that should fix that problem if you're following along all right so let's play again right we are in the game now and you'll notice I get a message that I created to say that data stores is disabled so it's not saving but if you haven't seen the Obby before everything is now in action so now I need to get through it by jumping uh across our obstacles and keep an eye on our on everything is working so you'll see now changed to checkpoint two and if I collect a box I've now got one box and then jump across here all right onto checkpoint 3 now I died now I didn't put a message in there however let's see if when we get up here our trigger is working all right no path for you so that is working and now I'll stop that there and we play again jump over to here and I got the trigger and I'm able to run out our box is animating and when I grab it I have now three boxes so of course you can make your um hidden pass go wherever you want you can make it go down here underneath uh wherever you like and have it have the play end up maybe taking a shortcut or something like that so I hope you enjoyed that and as a bonus um I will be making a game developer um sort of uh Dev uh video about this game and how I will create uh the level system in here uh in the future so that you can uh call this one level and then um move the player to another level so I look forward to seeing you in future videos if you found this video useful subscribe now for more information about my online courses go to Mr Brandon ross.com
Info
Channel: Roblox Coding Snippets
Views: 130
Rating: undefined out of 5
Keywords: roblox how to script, roblox how to script for beginners, how to script on roblox, how to script on roblox 2024, how to script on roblox for beginners, how to script on roblox studio 2024, roblox beginners guide to scripting, roblox coding tutorial, roblox coding tutorial 2024, roblox scripting basics, roblox scripting for beginners, roblox scripting tutorial, roblox scripting tutorial 2024, how to code on roblox, roblox studio, Obby Ideas In Roblox Studio #7: Hidden Paths
Id: LeT7Lbsyfik
Channel Id: undefined
Length: 36min 56sec (2216 seconds)
Published: Sat May 04 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.