Hey everyone! After seeing @Widgeon’s creation on Twitter (https://twitter.com/WidgeonRBLX/status/1239264957000105986) where he seemingly generated real roads (and buildings), I decided to attempt to replicate it and open-source a module for everyone to use!
I present to you, RoadGenerator!
RoadGenerator is a module script that I put together that will allow you to generate real world roads from a JSON file containing the road data.
How to use
Using RoadGenerator is quite simple. First you need to obtain your JSON file containing the road data.
Obtaining the JSON file
- First, navigate to https://www.openstreetmap.org/export.
- Then find any area with roads that you’d like to convert into Roblox! For example:
- Once you’ve found the roads you want to export, press the blue “Export” button! You should get a file named something like map.osm
- Navigate to a website that allows you to convert .osm files to .geojson. I personally found that https://mygeodata.cloud/converter/osm-to-geojson works very well.
- If you used the above website, you should see this screen with a section titled “Input Data”. Under that in the box titled “Input Layers to Convert”, you should remove all types of layers except “roads”. After that your screen should look similar to this:
- Press “Convert now!” to download a file titled “mygeodata.zip”. This zip file should contain a file titled “roads.geojson” somewhere.
- Once you’ve located “roads.geojson” in your “mygeodata.zip”, open it in a text editor. I personally use Notepad++.
- Select and copy all contents of road.geojson.
Now for the fun part!
Generating the road
- Assuming you’ve got the RoadGenerator modulescript in a game, expand it in the workspace and open up the module inside of it titled “RoadData”.
- Near the top of the RoadData modulescript, you should see an empty multi-line string stored under the variable “Data”.
- Inside the multi-line string, paste all the contents of roads.geojson.
- Finally, run
RoadGenerator.generateRoads()and you’ve got your roads!
You are also able to customize the generated roads.
RoadGenerator.generateRoads(colorRoads, drawPoints, roadWidth, scaleMultiplier)
colorRoads - can either be
false. If set to
true, it will color each road it’s own unique color!
drawPoints- can either be
false. If set to
true, it will make the points that make up the roads visible.
roadWidth- can be any integer, the roads will be that many studs wide. Defaults to .5.
scaleMultiplier- can be any integer. The lower the number the smaller the road layout is. Bigger = a larger scale layout, roads longer and spaced further apart. Defaults to 10000.
Viewing the roads
In case you are curious, you can also view the names of the roads! If for some reason a road doesn’t have a name, it will be called “Unknown” when generated.
To view the road names, open up the model in workspace called “Roads”. It contains all the generated roads as models!
Here is Park Place, the road that Roblox HQ is on!
As you can tell from the screenshots, this is not 100% perfect. For example, there are gaps where roads turn. However, as this is open-sourced, you are welcome to fix anything you encounter! If you feel like it, you can even add onto this script however you’d like.
If you do happen to make any fixes or add anything and you’d like to share it, feel free to post it in the replies! I love seeing what people are able to do with my creations.