Advanced Roblox Scripting Tutorial #15 - Gamepasses | MarketplaceService (Beginner to Pro 2019)

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
all righty guys it is the Deaf can hear back with a brand new video and sorry it's been like two weeks since I've uploaded I want to upload more but but I want Thanksgiving break now so that's good alright anyways so welcome back and in today's video I'm gonna be teaching you about game passes all right so game passes what our game passes okay so if you guys don't know what game passes are which you which you should but they're basically things were okay they're basically things or like kind of like products that you can buy and then you can use those game passes to actually implement new stuff into your game so for example you can have like a two x XP game pass so that way if someone buys it every time they get XP they get two times XP all right that's pretty self-explanatory but I'm gonna be teaching you guys how to make those and then in the next tutorial I'm gonna teach you about deaf products which are pretty similar but except you can buy them as much as you want so yeah they're both very useful and obviously they're very good to know cuz that lets you monetize your game make money from it so that's probably you know pretty important anyways so first things first go ahead and go on roblox studio now you can use one of your old games or any game but for this example I'm gonna make a new base plate just to make it clear so if you have a new game or if you have a game already just click on it and go and open it up now first things first we need to actually have a place to upload our game pass too so we need to actually publish this game to roblox so if you already have the game publish you don't have to do this but go ahead and if you don't if you okay if you don't need to have a base plate like I do then just hit file and then publish to roblox and then we're gonna hit create new right here okay and then we're gonna name it game pass tutorial you can name whatever you want that's what I'm gonna name it to keep it clear and then we're gonna go ahead and hit just hit create place there we go umm cool alright now we're gonna hit next and now our game was on roblox right this is the next step we need to actually go to roblox what let's go to the robox website so go ahead and go to your browser whatever browser you have and then go ahead and go to roblox calm okay and then go ahead and hit create right here and then it's gonna bring you to this page all right so now that you have are now that you're on this page you can see all your games go ahead my creations I hate games and then as you can see let me refresh real quick so I can show you my game is right there okay so what I'm gonna do is I'm gonna go ahead and click on this alright and then I'm going to go down here and it says create game pass okay now if you have a game already find your game and then just hit create game pass all right so the Nick regain passed it every go and then now we're gonna actually make our game pass so this is where you make your game pass and as you can see here says targeting game game pass tutorial and then you have to upload an image for your game pass and if you name it and then you put a description for it so that should be right already so change this to game pass if it's not already and then as you can see here it says game pass name for this game passed I'm gonna make a simple simple game pass it's gonna give you a sword okay so we're gonna name it give sword there we go and then we're gonna just put a description this game pass game oh my game pass gives you a sword boom alright cool and then we're gonna go ahead and hit preview and oh we've just like the image file my bed alright make sure you select an image file right right here so find your image I already have it pulled up I'm gonna use this little emoji thing I don't know why but just find any image you want make sure it's family friendly so robots approves it and then you just go ahead and click on this right there okay and therefore rename it again so we'll name it give sword there we go and then we can hit preview and then it's going to go ahead and prompt us here if everything looks good and at the formatting is a bit wrong for some reason some reason it's like a little like a it goes like a diagonal line I don't know why it's like that but that looks good so we're gonna go ahead and hit verify upload and there we go now are there's a game fast right there alright so now I'm gonna go ahead and click on my game fast and this way I can get the game pass ID all right so go ahead and go up here and double click on this little number or if you have to select it like that and then right click and then hit copy this is our game pass ID and we're gonna need this to check if our game passed is is you know checking just to check okay so go ahead and copy that over and then we're gonna go ahead and go back to roblox to you oh there you go all right so now what we're gonna do is we're gonna go ahead and insert a local script yeah okay yeah we're gonna insert a local script to prompt it and then we'll set it up so where it actually does something all right so first things first let's go ahead and make the Louisville script here we go we're gonna rename it to prompt game Pass you don't have to rename if you don't want to I just like today my scripts and then we're gonna go ahead and start trippin all right so first things first when you use the game pass you're using the service called marketplace service okay so we're gonna go ahead and define this service which is called marketplace service okay and we're gonna go and do market local marketplace service equal to game : get service marketplace service there we go and then we're gonna go ahead and type our game pass name it okay so this is important go ahead and do local game pass ID is equal to and then paste your game pass ID so you can right click and hit paste or press control V this is important because we need have our game pass ID obviously and that way we can use it all right cool all right so next we're gonna go ahead and do a we're gonna write a function that's gonna prompt the game pass okay so we're gonna go ahead and name this function local function prompt purchase okay there we go alright now this rongkhun is basically gonna it's gonna let us prompt a game pass alright so how you do that how you actually get that little screen up you know where it says oh do you want this game pass my blah blah and then you can hit by now or cancel you know you probably seen it before how do you do that is you use this function of marketplace service called user owns game pass actually wait no sorry sorry use a function called prompt game pass purchase okay and then you put two parameters in here which is first a player and then the player you want a prompt to sue and then the game pass ID okay now obviously there's more to it than just this this is how you prompt it but we need actually you know like make sure prompts right I don't notice when that but we know that we have we need to add some more to it okay so first things first we want to actually check you don't have to do this right but I want when I make a game pass I check first if the player has the game pass okay so we're gonna go ahead and define our player we're gonna do local player is equal to game dot players dot local player and then we're gonna do local has pass like has being passed as you put a false just because we're you know right now that they don't have it and then we're also gonna wrap this function in a peek all actually no way no no no for frecce sorry to check it we're gonna wrap that into Pico so we're gonna go ahead and do local success is comma message equals P call function there you go and then we're gonna do has pass is equal to okay and this is another function of marketplace service which basically checks that the user owns the game pass okay now if you don't know what this P call means yet just just wait a sec I'll tell you so we're gonna do local success comment message equals P golf function and then it has passed equals marketplace service user owns pass any pass async player dot user ID and then game pass ID okay so what this function does I'll clean this whole thing for you real quick so what this is the P call first of all if you don't know what that is you should be for my last tutorial but basically ap call basically what it is is it's a function or yeah I guess it's a function that basically you can wrap other things in so like we wrapped this right or in the P call or we put this in the P call okay we're at the rep yeah so basically what it does is if there's an error then it doesn't break the whole script that's what it does simply okay so I know it looks might look weird you never seem like local success comma message equals P call another like weird if ref it don't worry and then for this part we're gonna go ahead and set has pass okay so this function or this variable here that's called has pass which is currently equal to false we're gonna set that equal to marketplace service and then a function a built in function by roblox that's that says that calls or let that's called user owns game path async and then the two parameters are plated out user ID so the idea of the player right you so you don't just do player name because that ID never changes you need to play dot user ID and then you do the game pass ID so which one do you want to check right so basically roblox will check which one it is and then we set it equal to the variable has passed because it's gonna return true or false okay so if we print has passed and we have it it's gonna pre true and if we print if we print has fast and they don't have it it's gonna be false okay so basically that's what that does alright hope that makes sense alright next we're gonna go ahead and do if not success then warn air while checking if player has the game pass okay so basically you don't you don't have to do this but warned also you don't know warned is it's basically like printing but it's like in yellow text that's what that's what it is recently and then you can just go ahead and that's it alright now you don't have to this part right here this is just this is useful if you're like debugging or something like that right and basically if this function doesn't work or this function doesn't even I'm sorry if this doesn't work right then it's gonna it's gonna print or it's gonna be this local successful equal false okay so it really says if not success then okay alright anyway so we don't need that right now start that confuse do but we don't need that okay so we're gonna go ahead and do if has passed so we're gonna be like okay if the player has to game passed well then print player already has the game pass okay cuz there's no point in printing or there's no point in like prompting the player if they already out of the game path see what I'm saying so next we're gonna go ahead and do else right so if if if has pass is equal to false okay and that's what else does right we could do if has passed equal to true but basically that's the same thing as that's that saying the same thing is saying if has passed okay we'll make sure you for now just make it simple and then else and then we're gonna do that marketplace service prompt game pass purchase and then we're gonna what player do you want to prompt well the player in the local script and then we're gonna do a game pass ID there you go so now we're gonna go ahead and copy this function name and we're gonna call the function just down here okay now obviously maybe you wanted to call it if the player like touched a brick or something like that which actually we can do that let's go and make a part here and we're gonna call it cool part all right now we'll call it like game pass the zone like you know if some games have a zone like a VIP area that's that's what it would be so we're gonna do actually I'm not sure if you should do a touch in your local script but yet never never mind heat you get the point though okay we're both later because you may have to use a remote event for that if you want to make it work right so just you just know that this function based right here it's gonna prompt to you and that's gonna be the one that says oh by now or cancel and do you want to buy this game pass or whatever you know I'm saying anyways alright so now we have that we'll put a wait in here just let it wait but let go ahead and test it real quick and actually okay okay okay I'll just print it alright so let's go ahead and play it real quick I put that weight in there so here we go and what's gonna happen is after one second it's gonna print play already has to game pass now I know I never bought the game pass but I uploaded the game pass so by default I'm gonna have it so what I'm gonna do is actually I'm gonna I'm gonna make it I'm gonna copy this part right here I'm gonna make it actually prom me even though I don't have the game pass alright I know I don't have it I'm gonna make a problem either way so here we go and now we're gonna go ahead and see it when it prompts you already have it it's just gonna say this it's gonna say you already own this item your account has not been charged okay that's what happens so yeah alright now delete that out of there okay and now we want to make sure when you get the game pass and when you buy it it actually does something right so we're gonna go ahead and insert a server script okay in here and we're gonna call it a game pass oh crap I'm an I'm gonna call it game pass and ler alright you don't even if you don't want to but I like the new UI scripts okay alright so first things first we're gonna have to define the marketplace service I'm gonna copy it over cuz that I like to save time and then we're gonna get the game pass ID again so we're gonna copy that over as well and then we're gonna go ahead and use this function of marketplace service called prompt game Pass purchase finished okay so this may not like may not make sense at first bare with me it will trust me I'll explain it once I write it okay so here we go so first things first we're gonna write this event okay so the vents call the marketplace service dots prompt game Pass purchase finished okay now that I know it's a really long name for an event right but basically it makes sense so two minutes alright it means prompt game pass purchased finished okay so whenever like a game pass prompt pops up and it finishes either they hit cancel or by now that means it's finished and every time that happens it's gonna call this event and then you'll be able to write to it or you'll be able to do whatever you want right so it's gonna fire this event off right now so every time that happens okay I hope that makes sense alright so yeah we have that there and now there's also some printers they're all just there's also some parameters you want to put in there first things first you want to put the player obviously you want to know what player bought it and then you want to do the purchase pass ID so what game pass did they purchase right and then we're gonna name working for another parameter in here called purchase six purchase success okay so if it was a success all right there we go now whenever this event runs its gonna go ahead and give you all these variables I'm gonna have all these parameters in here which you can use to write more code okay alright so we're gonna do if purchases success equals true right so if it was true that's good but we want to make sure that purchases the right game pass right so we want to do if person's testing was true and I know you mean you may have never seen an before I don't know if I explained it or not but basically an is like it's just like an if statement but you make sure this statement is true right and you make sure that this statement is true now the statement we're gonna put here is if the purchase I or the purchase pass ID is equal to the game pass ID okay so it's just making sure but that both of these statements are true all right and it makes sense right you want to make sure they've actually bought it and what it's successful and then you want to make sure that you want to make sure that the game pass ID is equal to the purchase price ID so so what game passed if you want to fire you know I'm saying and I'm gonna make sure that C for that all right so then what we're gonna do here is we're gonna just print we're gonna do player dot name and then we're going to concatenate a string real quick and we're gonna say purchase the give sword game pass okay because we know what's the gifts or game pass all right and then that's it there you go so now when we buy it is it's what that's what's gonna happen so watch this and actually we're not gonna be able to look so if you see over here right we're gonna go ahead and actually try to buy this right now right but it's not gonna pop up obviously because we didn't call the function the local script so what we're gonna do since we already have it we're gonna go ahead and start a new server okay so go ahead and go over to test right here and then one player and then we're gonna hit start and now this basically makes a local server for you so you can actually like like test something it makes an entire server for you right all right so now this is the server window right and you can see like see that I have another this is the player window right here so you'll see me spawning see I just spawned into follow this guy and then you see here this is a player okay and up wait a minute it just wait a minute maybe okay okay wait we need to restart or go back to UM game pass tutorial and then clean up hit cleanup that's gonna close everything out you out for you um the reason why it said that it's cuz I need to wait longer here well we'll make this wait five just look and let it load or just so that we see it alright we're gonna go into that again go ahead and hit start and then it's gonna open up the windows for you again so there you go this will be my server so I can see everything happens if you guys never used it before so this is what it is and then it's gonna open up my actual client right here and here we go okay so now wait five seconds and then it should prompt me okay now it says this item is not currently for sale your account has not been charged and oopsie I made a mistake you're right this item is not currently for sale okay so let's go ahead and go back to roblox or the website real quick sorry about that all right so I actually made an oopsie okay I forgot to actually make it for sale I didn't set a price for it so how is someone gonna buy if is not for us there's no price so go ahead and go ahead and go ahead and go back to your game pass all right and then go ahead and hit configure we right click and then hit configure okay and then we're gonna go ahead and actually make it make it cost something all right and then as you can see here it says this and then hit go to details and then I mean it's not working what a man wears it that I forgot okay if you you should find the place where it says okay yeah sales okay sorry about that all right go to sales and an item for sale and then you click yes or click a little like the on button and we'll sell for 50 robots now don't worry you don't have to actually buy it whenever you're running it in here so it's gonna say as a test purchased all right so there we go we'll make it 50 or every much you want you can make it 500 million who cares right we'll make it 50 all right I will hit save and there we go now it's for sale all right so now we're gonna go ahead and go back to here he'll clean up again and we'll hit test one more time now we're not done after this actually we have one more step which I'll show you but here we go okay okay it's the server and then here's our client and then once that lowest we wait five seconds and then it's gonna prompt us okay do you want buy the product give sword for 50 robux buy now and then it says your purchase of gifts or succeded 50 roebucks this was test purchase they're just a test you don't get charged no no honey thing and then you'd okay and then what happens is you see that it printed down there because the event went off and it said player 1 print purchased the give sword game past in my name and here's player 1 because the testing server so there you go now I actually didn't add the function where you actually get the sword so I'll do that real quick let me go ahead and go from the tool box I don't really like any free models but obviously this is just for learning so we're gonna go to sword and then we'll insert roblox's basic sword in here and we're gonna hit I hit yes to put in the starter pack but don't put it in there when you get your sword put it in like rep storage I guess and there we go and then let me go ahead and actually sorry it's sorry if you can't see that but that's what it says let me go ahead and actually define local let me go ahead and find a replicated storage and they get the sword defined as well so I can give it to myself so local game gets service replicative storage and then we're gonna do a local sword is equal to replicator storage wait for child classic sword there we go and then we're going to do is we're gonna do sword dot parent is equal to player dot character there we go that should work now so now we're going to test it one more time to make sure it works and it should alright guys so we actually have one more feature what we need to do actually is program to make it actually like make it so whenever you join the game in order of the game pass bought make it so you actually like run the game past that sasha and i mean ii i mean if that made no sense so here we go it should work and do you want to buy it yes i want to buy it came it to me please thank you every guy got my sword game that's awesome it's awesome it's awesome alright cool cool cool also guys if you're watching this moratorium and you are def King fan first off let me say I appreciate you so much thinking for supporting my videos and I'm glad this teaches you something seriously like I wouldn't do it if you guys weren't watching but yeah okay um also what I was gonna say though um if you guys don't know I'm actually I have another youtube channel this isn't my main channel I have a hundred thousand subscribers in my other channel and I'm actually a video star program or I'm in the video star program so I have a code called code tap wherever you buy robux you can use it so if you guys want to use code tap whatever you by roebucks I'll show you where you can where you can use it if you go to roebucks over here okay and then you hit the you get like some by roebucks thing right here and then you go down here and then it says you see have a code to support your favorite roblox video star click here and there's tech tap that's best my my me my main youtube channel name is tap water but just to make it simple I used tap so yeah yeah that does support me so if you guys want to do that it gives me like 5% of the money that you spent you don't lose any roebucks you get all your robux don't worry you just get I get 5% of the money so that's kind of cool but yeah I appreciate you guys use that it's pretty cool and yeah doesn't mean that's a way to pay me back I guess alright anyways also one quick thing before I start before I continue the video um if you guys don't know actually uh this channel like the defconn channel I've actually recently hit the requirements for monetization so I actually have ad soon so I'm sorry but I don't know I probably won't make much money on a sleeve just because of the low amount of views I get but I mean still it's kind of cool I guess just the fact that I gotta monetize in general but don't worry guys I'm not like Brooke you don't need to like give me money or anything but if you do want to use a KO that's pretty cool but yeah also um actually that's it alright cool all right so let's go danke born is where we have one more thing to mention and then we'll be finished okay so the next thing we have to mention is the Obama bomb we want to make it so the the player actually gets their sword when they join the game let's say that the player already has a game pass right let's say the player they left the game they come back and they have the game pass okay good awesome you gotta bring your bottle game pass but it's not gonna give them the sword right cuz look if I hit play I have the game pass because I uploaded it right but if I hit play right now I don't have the sword I don't have it and that's because we give the sword whenever that event goes off and obviously if you already if you already have the game pass you're not gonna be prompt in that event again so yeah unless you were it'll be prompted it and then you hit okay and then it would check but still you don't want that happen every time just to just to get your sword so what we're gonna do is we're gonna go ahead and add another script or you can do it in the script either one doesn't matter but I'll make another script just simple and we'll call it check game pass and then we're gonna go ahead and write that all right so what we're gonna do for this is go ahead and define marketplace service again there we go and actually we'll just copy the all this stuff cuz we're gonna need that oh crap copy all that stuff and then we're gonna copy the game pass ID as well and then there we go all right so what we're gonna do is we're gonna do game dot players dot player added so I was gonna pledge on the server this event will run you know you guys use this event all the time I'm sure if like leader leader stats and stuff like that so we're gonna do local has pass by default it's a little false we're gonna just check and then we're gonna use that same event the same function we used in the in this to prom the purchase we're gonna check if it has that so I'm just gonna paste it over I'm gonna copy paste it over so I'll just copy that and then I'll hit paste right there and we already used this event I explained already but basically I said it's just gonna check if I have the game pass right by doing player player ID and then we're gonna do if has passed is equal to true then actually I'll just write that told you if has passed as you go to true then prints player has the give sword game pass and then we're gonna do we're gonna make the sword dot parents equal the player character that's how you cup a sore if you guys didn't know you make it so you make it equal to the player character all right they really that should work and then we're gonna go ahead and see if it works and wait a minute that didn't work on tack print player already has to wait wait wait wait wait oh okay wait hey let me hit play again sorry I don't know why I didn't work one sec player has this give sword game pass okay so then it should be sort wait wait I made a mistake sort about parent is equal to player character wait I'm confused why doesn't that work what what wait wait wait wait um okay wait it should work right I mean we just did but this for the other thing so it's it's saying that you have it and then it should be telling this the parent of a sword equal to the game pass or equal to so it moves it and and then it does put this no it isn't the sword in there at all Oh we'll just it to player dot backpack all right well okay we get why should we're gonna define the character up here we'll do local yeah yeah actually you can't I don't think you can do player dot character and a um in a I'm sorry I can't think in a server script that's why alright so we'll do local charge equal to game dot workspace get player wait a minute get character there was a function I forgot the name of the function I'm using in a while we'll just do this we'll do local char is equal to game dot workspace stuff fine first child player dot name all right now that should work chart okay there you go oh wait let me test this make sure it works DP if don't write that if you don't want to but make sure it works first oh I know what it is the player isn't loaded yet let's wait one second before we run this I'm just let the player load end or the character load and sorry oh okay I'm really stupid okay yeah don't wait one second because the vets gonna run and then it's not gonna fire because I was on a wait so put the weight inside of the events okay come on now there we go finally okay so yeah you couldn't do player dot character in a server script all right so basically I have a sword now and basically I didn't have to actually buy it because I already had the game pass it worked already so that's cool so what you want to do is make it wait a second right because you want to make sure the character can load now what you normally need to make it wait is you actually do like repeat until until repeat wait and then you can do like until why don't why France sometimes everything goes seriously I forget the syntax of everything it used to repeat a repeating loop but I forgot the syntax for it so I'm just not gonna write it everybody that's pretty much it I hope you know the video I'm sorry was so long but I'd like to go in depth with my videos and explain very very good so I I was gonna come shorter I'm really sorry they're so long seriously it's a problem but um I hope I spend everything real for you guys seriously think this is like I feel like if you've never even scripted before you could just probably still understand to this tutorial so that's pretty cool anyway guys that's it hope you enjoyed it I'll see in the next one face dev oh yeah use code tap and also dev products coming next alright peace
Info
Channel: TheDevKing
Views: 46,498
Rating: undefined out of 5
Keywords: TheDevKing, Roblox Scripting Tutorial, roblox, studio, coding, tutorial, marketplaceservice roblox, roblox marketplaceservice, gamepass roblox, gamepasses roblox, how to add gamepasses to your roblox game 2019, how to add gamepasses on roblox, roblox gamepass tutorial, how to make gamepasses in roblox studio 2019, how to make gamepasses, how to make gamepasses in roblox, best roblox gamepass tutorial, marketplaceservice tutorial roblox, how to make money on roblox, roblox studio
Id: 3hMmhmC18RA
Channel Id: undefined
Length: 29min 53sec (1793 seconds)
Published: Wed Nov 27 2019
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.