How could I set up claimable "chunks" of land via a script?

Hey there.

I’ve been popping in every now and then for pointers on some things, but I am about to begin work on a major part of my game, which is claiming lands.

I want a player, such as a faction leader, to be able to claim chunks of land that they can build on. You’ll realistically be able to build anywhere on the map, but only the stuff in claimed plots will be saved / persistent. For the record, I am building a persistent medieval world, and land claiming would work similar to something like the Towny plugin on Minecraft, if you’re familiar.

I don’t want to use individual parts to create plots if I don’t have to… the realms / maps I will be using in this project will be very large and I do not think doing that would realistically be feasible for my time.

I’m interesting in knowing if there is a way I could somehow generate plots of land and be able to, when saving persistent data, to see what buildings are within that region, so I can save them. I’ll also need to access the plots in real time, as well, to see if you have faction permissions to build in that claim.

Being able to visualize the plots would be valuable too, for both claiming those plots as well as seeing both your own and other faction’s claims.

I’m not necessarily asking for code, but just wondering if something like this would be realistically possible with ROBLOX’s engine, and for some pointers in the right direction about how to implement such an idea if possible.

I know this probably sounds like a complicated idea, so ask any questions you may have and I’ll try to clarify on my goals here. Thanks in advance for the help :slight_smile:

3 Likes

this is very possible! (but would require a lot of raycasts)
You could start off with a mouse + workspace raycast that detects where the mouse is, then create some surface gui, server tabes…

3 Likes

Is your world procedurally generated? Is it limited or infinite? Is it voxel/“block” based (a la Minecraft)?

2 Likes

The world is a set persistent world. Meaning, I will have a map already set in place that the user will be able to build on and claim land on. So, limited, rather than infinite. It’s also not voxel-based.

2 Likes

Well, this depends.

Likely a nice way is to have an invisible block. Then your options change here:

  • You could make it so when a player presses a button in land they want to claim they claim it.
  • You could make it so when a player holds down a proximity prompt or a button the land gets claimed.

Make sure the claimed land has an object value to state who the player is.

This is all just basic knowledge I have from making a tycoon! If you need any more help let me know. I can also provide scripts and roblox files if you need further assistance.

(If you want to quickly add these land claiming things almost everywhere you could make a script to spread them.

2 Likes

Hmmm, maybe figuring out how to change the mouse’s coordinates (or perhaps even the player’s) into detecting which plot they’re on/looking at?

That still begs the question of how it would be best to implement a plot generation system that could remain consistent for the purposes of loading it back into the persistent world.

So, to that end, how would a surfaceGUI work with raycasting for this use case scenario?

2 Likes

Shoot I read that again . . . block based honestly is your best option. Sorry about that, you could probably just make like a townhall structures in these cities or whatever, and make it so when the player entires the building they have the option to claim that area.

2 Likes

Haha it’s alright. I was just typing out a response to the other reply you sent.

I am skeptical of using a parts based system, hence why I am here looking for alternative ways to do this if I can find it. My main concern is performance. The maps for each realm in my game will be anywhere from 5kx5k to 10kx10k, and will all be persistent, dynamic, and interactive with moving objects like carts and horses (and maybe other livestock), draggable items like rocks and logs, and other stuff. Limiting the game where I can to help with performance would be helpful.

However, I totally accept that making a parts-based land claiming system with Region3’s or whatever may be my best bet. I’m just looking for other ideas :wink:

In re: the town hall idea; I could, but the plots will be too small to effectively do that. Instead, I plan on letting faction leaders have access to some GUI or tool that will allow them to claim a chunk they are standing in, for a price or whatever.

3 Likes

Wait I thought of a good idea . . . what if you use teleportation service? That will probably cut off most of the lag and when a player enters another player’s town it could be a model town (essentially a static town). When you enter the server you are teleported to, it’s all moving and alive.

This may not be your ideal thought, but I think this would cut off lots of lag. I doubt ROBLOX could handle this without making it like this.

2 Likes

We’re doing something similar to this, but in a different way. The scope for our game and community is much larger than just that. We’re essentially replicating a world map and the player would be able to travel between persistent regions of the world.

I have no clue if I can post game links on this forum, but if you’d like to see a very brief and rudimentary demonstration you can go to my profile, go to my main group, and then go to the “Lobby / Map” game.

I think if there is no other option besides a parts-based chunk-claiming system then I’ll definitely have to experiment with it and see how ROBLOX’s engine can handle it and if I’ll need to modify the scope of my game at all.

I just had a thought, but is it possible to set up Region3’s without using parts? Perhaps I could do that and generate Region3’s in a formulated manner (so it’s the same every time) between two points on the corners of the map and assign values to those Region3’s, and then whenever you’re trying to place objects or do certain things within a Region3 it’ll just compare that to a set of saved data that gets pulled from a datastore. I don’t know how feasible this is, and I may also have a misunderstanding of how Region3’s work on ROBLOX lol.

2 Likes

You can post group links in DevForum! At least in PM, as far as I’m aware. It should be allowed.

Your game sounds very complex, I hope you have good luck with it! Share when it’s done please (;

1 Like

I certainly will. It will be fun and interesting, I hope.

2 Likes

You definitely can! If your chunks divide the map up into a uniform square grid, you can just round the player’s X and Z coordinates to the nearest S, where S is the grid size.

If you have other shapes, please post a drawing or something to better explain your situation. No matter what shape, detecting which shape any given point falls into is possible.

1 Like