Med Written By jig_x

Randomized Map Created on: 15-07-2019

Gets a random map that you made and places it into workspace.

What you need,

  • Maps (or just test with different colored parts)

You need to know,

  • How to use math.random
  • How to use tables
  • How to use basic functions & loops

Programming,

First add you maps to a folder or model, which ever you like best, and rename it. Then put that into ReplicatedStorage. Next insert a script into ServerScriptService and write the following lines of code in the script

local MapsHolder = game.ReplicatedStorage:WaitForChild("MapStorage")

local function GetNewMap()
	if #MapsHolder:GetChildren() then
		local RandomMap = MapsHolder:GetChildren()[math.random(#MapsHolder:GetChildren())]
		return RandomMap
	else
		print("No maps")
	end
end

Technically that is what you need, but if you want to add that map into workspace, you add this.

local CurrentMap = nil

while wait(15) do
	if CurrentMap then
		local Map = GetNewMap()
		if Map then
			Map.Parent = game.Workspace
		end
		CurrentMap:Destroy()
		CurrentMap = Map
	else
		local Map = GetNewMap()
		if Map then
			Map.Parent = game.Workspace
		end
		CurrentMap = Map
	end
end

What this does is every 15 seconds, a new map is recieved and replaces the old one.

Med Written By jig_x

See jig_x's profile on Roblox

Discussion