Hello everyone, I am Jdubygamer. I am currently making a game called “Carbine Legends”. It is similar to Phantom Forces but also completely different. And as I am new to scripting and am still learning the basics, how would I want to go about making my game played on a different map for each round?
Would I have to do something with spawn points, teleportation, or anything else? I just have no idea and am trying to save some Robux here by scripting this type of stuff by myself.
Map voting is a bit more complex, but there are tutorials on YouTube you can use to get started if that’s what you’re looking for. Perhaps this tutorial may be of assistance.
If you’re thinking of taking an easier route, you can utilize math.random
Place all of your maps in ServerStorage, perhaps in a folder titled ‘Maps’, and use math.random to have the game pick a random map out of the batch. Clone the chosen map and parent it to workspace, and there you go.
What I stated was the bare minimum basics, but you can build and expand the complexity from there.
Furthermore, you can use attributes or configurations inside the map models that store information such as Vector3 values that can be used for spawn points.
So would the #maps be the number of maps that I want to be included in the randomization? I might keep it as a random map when I release the game.
And how would I let it know when to change the map and where to spawn people? Would I just put that in the script or is that just the map randomization, not including where to spawn and when to randomize the map?
The code I provided above will automatically account for every map you have in the map folder. The “#maps” means the amount of children (in this case, maps), the “Map” folder contains.
maps[math.random(1, #maps)] means you’re randomly choosing one map out of the number of maps in the folder.
When changing the map, you would simply set remove the current map from workspace:
map:Destroy()
and then repeat the process.
As for spawning, refer to my prior post. You can put Vector3 values inside configurations or attributes in the map model, which can then be accessed by the script to understand where to spawn players.
Alright. Thank you so much for your help! I haven’t gotten to the vector3 tutorial of AB’s scripting lessons, so once I learn that that should help me understand more.