Command to change the map

So I have 2 airport maps, I want to have them in the same place but it starts with Airport1 on.
Then I run :airport2 and it puts airport2 on.

Airport 1 is the departures terminal, 2 is the arrivals.

How can this be done?

2 Likes

Chat only command and make sure that if it`s the same airport don’t clone but if it’s different put all the players in a position they won’t fall of then clone the desired airport

I know this is not the best method but it is still worth it

Try this,

    game.Players.PlayerAdded:Connect(function(plr)
	  if plr.Name == "yourname" then
		plr.Chatted:Connect(function(msg)
			if msg == "something" then
				local clone = game["Whereitis"]["mapname"]:Clone()
				clone.Parent = workspace
			end
		end)
	end
end)

Ok so there are different ways on doing this. One way would be making your own set of commands while the other being adding those commands to an admin that you have in game. The first one is a lot easier and is what I have stated below while the second one is more advanced.

So what you first want to do it group them all or place them in a folder and name them something, the name I will use is airport1, so you can find it later in the script.

Then you want to make a script in ServerScriptStorage and put the following code…

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local Rank = plr:GetRankInGroup(groupID)
		if Rank >= 12 then -- Rank and above that can run the command
			if msg == ":airport1" then --What you want the message to be
				game.Workspace.airport1.Parent = game.ServerStorage
			end
		end
	end)
end)

game.Players.PlayerAdded:Connect(function(plr)
	plr.Chatted:Connect(function(msg)
		local Rank = plr:GetRankInGroup(groupID)
		if Rank >= 12 then -- Rank and above that can run the command
			if msg == ":airport2" then --What you want the message to be
				game.ServerStorage.airport2.Parent = game.Workspace
			end
		end
	end)
end)

Please note this is a very simple version and is typed up very fast.

1 Like

I would recommend using elseif instead of making multiple connections to the .PlayerAdded/.Chatted functions. I think you can also move the rank check outside of the .Chatted event so that you do not have to make an unnecessary connection.

I recommend storing the maps inside ReplicatedStorage so the client has access to them and, therefore, can download them while playing. I also recommend storing the map inside a container, such as a Folder or Model. Then, when you want to use the map, you can just do ReplicatedStorage.Map.Parent = workspace . If parts of the map are destroyed in-game (with explosions, for example) you’ll have to clone it instead to prevent wear and tear of the map overtime.

Something like this is never going to be instant, so a short pause dedicated to giving some time for the map to load is probably a good idea.

I’ll try this right now, thanks so much.

Question: Will the airport1 auto be default?

Can you explain what you mean by default?

Fixed, nvm, thanks for all the help ppl.