0:05 welcome back to the sandbox Tycoon
0:07 Series in this video I'll be showing you
0:09 exactly how to set up a plot system now
0:11 this system is not going to be one where
0:13 you choose exactly what which plot you
0:16 want instead we're going to be doing a
0:20 system where the server hands out plots
0:23 automatically I may do a series a mini
0:25 series that kind of adds on to this one
0:27 after the fact that adds in those
0:30 features that people request and
0:32 they didn't make it into the main
0:35 series but I'm not going to promise
0:37 anything but anyway we will get into the
0:39 video actually before that I'm just
0:42 going to promote my Discord server and
0:43 yeah so pretty much there my Discord
0:45 server is the best way to get in contact
0:49 with me and the rest of the you know
0:50 people that watch the videos so
0:52 subscribers or you know the community I
0:55 guess and essentially there's the you
0:57 know Dev support channel so you can you
1:00 know submit support on different for uh
1:02 you know you can ask for help
1:05 essentially there's project there's the
1:06 projects Channel where you can submit
1:09 your projects that you've been working
1:11 on there's a whole ton of stuff I'll
1:13 show you a you know screenshot of all
1:15 the different things or a video or
1:17 whatever showing all the different
1:18 things you'll have to come and see what
1:21 all come and join the server to see what
1:23 all of them are but
1:25 yeah anyway hopefully I'll see you in
1:28 the server and let's just move into the
1:30 video okay so the first first thing I'm
1:31 going to do is I'm actually going to
1:34 create a folder in server script service
1:36 now I actually forgot to do this in the
1:40 first video so we're doing it here but
1:41 anyway we're going to create a folder
1:42 and we're going to call This Server
1:44 modules the reason for that is we're
1:47 going to put a module script in here you
1:49 may be asking why don't we just put it
1:52 in modules well let me just let me let
1:54 me so we're going to call this plot manager
1:56 manager
1:58 okay and in here we're also going to
2:01 call this plot
2:03 manager we can just go ahead and duplicate
2:04 duplicate
2:08 that and basically what this module is
2:10 going to do is it's we're going to
2:12 create a server script actually here
2:14 we're going to call this plot man or
2:17 plot Handler so plot Handler basically
2:19 just a different name of saying plot
2:22 manager uh but the module is essentially
2:24 going to assign a plot now the module is
2:27 going to hold the functions to do that
2:28 we're also going to have another
2:30 function to
2:33 return the plot to the server now the
2:35 reason why we're putting it in server
2:39 modules and not modules is we want we
2:43 don't want the client having access to
2:45 setting players plots like that wouldn't
2:47 make any sense exploiters would go crazy
2:50 with that one they would set people's
2:51 plots to different things or whatever I
2:54 don't know they would just call it on
2:55 different things and they would
2:59 basically yeah go crazy so we don't want that
3:00 that
3:03 we're doing it in server modules so that
3:07 the client cannot cannot physically do
3:09 anything so let's just go ahead and go
3:11 into plot manager and create a couple of
3:13 functions so the first function is going
3:15 to be for assigning the plot so we're
3:18 going to say plot manager Dot and then
3:20 we're going to do
3:22 assign uh plot this is going to take in
3:24 two parameters the one first one is
3:25 going to be the location and the second
3:28 one's going to be the player that we are
3:33 now in this function really all we're
3:35 going to do is we're going to make a for
3:38 Loop which is going to be four IV in
3:42 pairs and we're going to loop around Lo get
3:43 get
3:46 children we're going to say do
3:49 and we are actually going to yeah so I
3:52 guess this is it actually then what we
3:54 can say is we can check if and actually
3:56 I'm going to change V to
3:59 PLT uh just for the sake of making this
4:03 more readable so if PLT Dot and
4:04 basically what we're going to be
4:08 checking is if this owner value is empty
4:10 so if it is we're going to set the plot
4:13 to that player so we're going to say if
4:17 plot. owner. value is equal to an empty
4:20 string then we're going
4:25 to return or we're going to set PLT do whoops
4:26 whoops
4:29 owner. value
4:34 uh to whoops plr
4:38 do pl.
4:40 name so you may be wondering why are we
4:43 not just saying if PLT is equal to nil
4:46 well string values actually
4:49 don't you for some reason at least in my
4:51 experiences they
4:54 don't empty values are equal to an empty
4:56 string and not nil for some reason I
4:58 don't know why this is if you know
5:00 comment down below and help people out
5:04 but if you don't just know that this
5:06 value is an empty string and not nil I
5:09 don't know why it makes no sense
5:13 but yeah it is that's the way it is and
5:15 yeah so you can't check if it's equal to
5:17 nil you have to check if it's empty
5:20 string for this to work so then of
5:22 course we also have to break out of this
5:25 Loop so we're just going to call Break
5:28 um or write out the break statement
5:30 which basically is just going to break
5:32 out the loop because we don't want to be
5:37 setting multiple plots to our player
5:38 it's kind of the thing we're trying to
5:43 avoid putting this in server uh server
5:46 modules uh so the second function is
5:48 going to be again we're going to say
5:50 plot manager Dot and this is going to be
5:52 return plot
5:54 okay again this is going to take in two
5:57 parameters the uh actually no we're just
5:59 going to give the oh never mind mind we
6:02 are actually going to need that one so
6:04 we're the same amount of parameters as
6:08 the other one so then we can also put a
6:12 four I PLT in pairs Loop we can loop around
6:13 around [Music]
6:16 [Music]
6:20 the children and of course I put an
6:28 needed okay so here instead of checking
6:31 if the value is equal to to this empty
6:33 string we are actually going to be
6:38 checking if PLT do owner. value is equal
6:42 to plr name and if it is we're going to
6:46 return PLT and then we don't have to
6:48 write our break since return already
6:49 stops the code from
6:52 running so the reason why we're doing
6:55 this function is this is going to be if
6:57 the client requests the plot then we can
6:59 easily just hand it out to them because
7:01 the client is going to need to know the
7:03 plot that they have
7:05 have so
7:06 so
7:08 yeah this is just going to be how we're
7:11 going to do it okay so now in plot
7:13 Handler we're going to need a couple of
7:15 different things so first off I'm just
7:18 going to get uh the player service which
7:20 is going to be equal to game get service
7:23 and then players if I could type then we
7:27 are going to get the uh module so we can
7:31 say local PL plot
7:34 manager equals require and then we can
7:36 give it not a
7:39 string scripts.
7:42 parent. uh server
7:44 modules. plot
7:46 manager and that's essentially going to
7:49 give us the plot manager it's going to
7:50 return the functions allow us to use
7:52 them as you can see if we type plot
7:54 manager dot it's going to give us a list
7:55 of the
7:59 functions so that's that so now we can
8:01 say when someone joins the game so
8:05 player added then we can connect
8:08 to we're going to call this function
8:09 we're actually going to declare a
8:11 function up here so
8:13 local function you may be wondering if
8:15 you're new to scripting and all you
8:16 should know this but if you are just
8:18 watching this the reason why we didn't
8:20 declare local is because this is going
8:22 in here and we don't want everything to be
8:23 be local
8:26 local
8:29 um so we Define local function and I'm
8:31 going to call this function I don't know
8:34 let's see what would be a good name so
8:36 what are we trying to do when the player
8:38 joins we're going to what assign the
8:41 plot so we're going to just we're going
8:44 to again call this assign plot and we're
8:47 going to give this plr and then we can
8:50 assign to or connect to sign plot so
8:52 when the player joins the game we're
8:54 going to invoke this function invoke
8:57 just means call the
9:00 function so all we're going going to do
9:03 is call on the plot manager assign plot
9:05 and we just give it the player that just
9:08 joined the game that's all there is to
9:12 it now we're also going to be making a
9:14 function so local
9:16 function and we're going to call it
9:20 request plot we're again going to give
9:22 pass the player now this is going to be
9:26 needing a remote function so we're going
9:29 to use a remote function here we're
9:30 going to do duplicate request placement
9:32 and we're going to call this instead of
9:33 request placement we're going to call
9:35 this request
9:38 plot so we're actually going to go and
9:40 get that up here so
9:44 local uh remote R RF is going to be
9:46 equal to we're actually just going to
9:48 get the replicated storage service so
9:51 local replicated whoops
9:57 look replicated storage equals game get
10:00 service replicated storeage
10:03 so then we can say that the we can just
10:06 give it the path so we can say
10:08 replicated storage Dot and then we can
10:13 see signals do remotes do functions do
10:16 request plot and that's all there is to
10:20 it then we can fire that when the when
10:22 it's called so down here we're going to
10:27 put it right above here uh remote RF do
10:30 on server in
10:38 basically on server invoke is
10:40 essentially when we call or we send
10:43 information to the server and then we
10:45 have to give it a function so we can say
10:48 on server invoke this is basically when
10:52 the remote function is fired or invoked
10:56 we can just set that to request plot and
10:58 we get rid of that so pretty simple syntax
11:02 all it's saying is instead of connecting
11:05 to the function we just pass in this
11:06 function here we don't give it
11:09 parameters unless well no we don't give
11:10 her parameters here we don't or open and
11:13 closing parentheses is what I
11:15 meant so what we can do is we can
11:18 essentially just return or first off we
11:19 need to check
11:21 check
11:23 um you know what actually know we don't
11:25 need to do anything we can simply just
11:28 return plot manager if I can type here return
11:30 return
11:33 plot of course we will have to give the
11:35 location I actually forgot about that up
11:37 here so the location in this case is
11:42 just going to be uh workspace do
11:46 plots yep or
11:49 lowercase so again we're going to need the
11:51 the
11:54 workspace plots and then we give it a
12:03 okay so now everything should line up if
12:05 we call return plot we we get the
12:07 location it Loops through if the owner
12:10 is equal to the name then we
12:13 return so now we have two functions how
12:18 do we use them well let's go down
12:21 into let's say client
12:25 placement and instead of in here instead
12:29 of function RF we are going to
12:31 going to just duplicate that line we're
12:35 going to call this get plot RF actually
12:37 you know I'm just going to call it get
12:41 plot and instead of request placement we
12:44 can just replace that with
12:46 plot so that's just going to get this
12:50 thing so we can actually just create a
12:54 variable to Fire and get the plot so
12:56 instead of workspace plots. plot one we
13:00 can set it to get
13:05 plot and then we can say invoke
13:08 server yep server so now this is going
13:11 to fire and whatever it returns whatever
13:14 whatever this function uh whatever this
13:17 function returns we're going to set that
13:26 works all right so let's see what plot
13:28 we were given so obviously plot one
13:30 let's just make sure we didn't get plot two
13:31 two
13:36 3 or four I'll click on plot one and as
13:37 you can see it worked we have the
13:41 placement system working it puts it into
13:43 the correct
13:47 plot and yeah this is pretty much it so
13:49 you may be saying to yourself well we
13:50 didn't teleport to the plot
13:52 plot
13:55 so that's actually quite simple now we
13:57 are actually going to do it a little bit
14:00 of a um whatever you call it we're going
14:02 to be doing it a little bit of a
14:04 interesting way so instead of actually
14:06 doing the math and calculating okay if
14:08 the plot is rotated this way then just
14:11 move it to here or something we're just
14:12 going to create a part that we're going
14:15 to teleport to so I'm going to create
14:17 four parts here so 1 2 3
14:20 four and I'm just going to select them
14:23 all so I can give them properties the
14:24 same I'm just going to make these
14:25 anchored we're going to turn C cide off
14:27 so there's absolutely no way that they
14:30 can figure out that they're here
14:31 we're going to set the transparency to
14:35 0.5 and then basically we just have
14:39 to put them in the place that we want so
14:41 we can bring
14:45 this right here can bring this one
14:47 one
14:49 right here by the way if you don't know
14:52 how to teleport to uh Parts like this
14:54 you just press F on the
14:56 keyboard so it's really actually quite
14:58 useful just going to put this one right
15:01 here and that looks good so now we can
15:05 just call these wonder is there a way
15:09 to no I'm just going to call each one of these
15:10 these
15:14 Telly so just like
15:17 that same thing with this
15:18 one that
15:21 one that one so now if we open up here
15:24 we can just say that okay this one goes
15:34 this one is plot three and then this one's
15:35 one's
15:38 obviously plot
15:42 four so we're going to put a script in
15:45 starter character scripts or maybe
15:47 starter player scripts I don't remember
15:48 which one I think starter character
15:52 scripts is what we're going to use
15:53 because that's whenever the character
15:56 load so that actually is good so we can
15:58 say that local character since this is
16:00 going to load in the character is just
16:03 equal to script. par because that's
16:06 going to be what it is and if we want to
16:08 test that out we could just print it out
16:09 I'm not going to do that I know this is
16:14 going to work but yeah so how do we get
16:16 the well plot well we're actually going
16:18 to go in here and we're just going to
16:20 copy what do we need we
16:23 need basically
16:27 this so we're going to paste it in we're
16:29 going to get rid of you know never mind
16:30 we don't need that oh right and we're
16:32 also going to
16:39 here put services at the
16:41 top and okay so now we have everything
16:43 that we need except we don't need this
16:45 one right here
16:46 here
16:49 so we're going to yeah what we're going
16:52 to do is we're going to say that yeah
16:54 we're going to request a plot so we're
16:58 going to say that local plot equals uh
17:00 get plot
17:04 and then invoke
17:07 server and then below that we can say
17:09 character set primary part whoops oh yeah
17:10 yeah
17:15 set primary part cframe we give it a new
17:20 cframe we can give it plot. X or whoops plot.
17:22 plot.
17:26 do cframe dox plot
17:30 do Telly do
17:32 cframe doy and actually on the Y I'm
17:43 ploty
17:46 dot cframe here we go so now we have all
17:48 of our
17:51 axes now what do we do we uh have to say
17:53 CF frame. new of
17:58 course so this should actually be it if
18:01 we hit play hopefully we'll teleport to
18:03 the correct
18:08 plot as you can see we did so that is
18:10 essentially all we have to do very
18:14 simple that's it so I'm just going to
18:18 call this teleport script or
18:21 teleport Char I'm going to call it teleport
18:22 teleport
18:25 Char and then finally I'm just going to
18:28 click on all of these teleport bricks
18:30 and make them fully invisible so we
18:32 don't know that we're teleporting onto
18:33 them and it doesn't look weird like when
18:36 I just tested it so anyway hopefully
18:37 this did help you I'm going to go over
18:39 the code one more time just to make sure
18:43 that it is you know making sense so
18:46 first of all we make a met plot or a
18:48 module it's going to contain two
18:49 functions the first one is going to
18:52 assign the plot so that's we Loop
18:54 through the location provided then we
18:57 check if the owner is equal to an empty
18:58 string remember we have to say empty
19:02 string and not a nle value
19:05 so yeah and if it is if this returns
19:09 true then we are going to sent that to
19:11 the player the player's name not the
19:12 player itself we're not using object
19:15 values like I did in the last series and
19:16 then of course we just go ahead and
19:19 break and these ends do the rest they
19:21 yeah and the function so anyway in the
19:23 second function this is going to handle
19:24 returning the plot so it's essentially
19:26 the exact same thing as this
19:29 instead well it's slightly different the
19:31 changed bit is essentially right here
19:36 this is the big point so pt. owner.
19:38 value so if pl. owner. value is equal to
19:41 the player. name or the player name then
19:42 we're just going to go ahead and return the
19:43 the
19:46 plot and obviously in plot Handler we
19:47 are just going to create a couple of
19:50 functions to handle those we may like I
19:51 created functions so that if we wanted
19:53 to add in something we don't have to do
19:57 it 100 times um I guess we would be
19:58 creating functions either way if I did
19:59 connect to a function but this just
20:01 makes it easier I like to create
20:03 functions that actually have names
20:06 anyway this just Returns the plot uh
20:08 when the client requests it and this
20:10 assigns the plot when the player joins the
20:11 the
20:14 game and of course in here we get the
20:17 plot from here as well as in teleport CH
20:19 and I'm pretty sure you probably will
20:22 know what this is so anyway that's that
20:24 I'll see you in the next video let me
20:26 just test it one more time just to prove
20:29 that it works
20:31 and here we
20:35 go that is that's all there is so anyway
20:36 hopefully this helped and I'll see you