I want the script to let all players in the server type the command spawn/MAP_NAME but I don't know how to change it so all players in the server can type the command. This script is for a singleplayer game or a one player per server game. Too make your job easier.
current_map = nil
names = {"YourNameHere","AnotherPlayersName"}
game.Players.PlayerAdded:connect(function(player)
for i, v in pairs(names) do
if v == player.Name then player.Chatted:connect(function(chatmsg) if chatmsg:sub(1,4) == "spawn/" then local map = chatmsg:sub(5, chatmsg:len()) if game.Lighting:FindFirstChild(map) then if current_map ~= nil then current_map.Parent = game.Lighting end game.Lighting[map].Parent = game.Workspace current_map = game.Workspace[map] end end
end)
end
end
end)

2 comments
Addendum, you shouldn't use Lighting to store maps in, roblox has services such as ReplicatedStorage And ServerStorage for that purpose. http://wiki.roblox.com/index.php?title=API:Class/ReplicatedStorage
How do i make it remove the old map and then spawn the new map?