Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Map command broken?

Admins = {"groovydino", "Player1", "Player","dragonmaster4111"}

game.Players.PlayerAdded:connect(function(player)
    player.Chatted:connect(function(msg)
	for i,v in pairs(Admins) do
   if msg:sub(1,5) == ":map " then
	for i,v in pairs(game.Workspace:GetChildren()) do
				if v.Name == "Big Fields" or v.Name == "Polar Regions" or v.Name == "Mountains" then
					v:Destroy()
					end
	
	for i,v in pairs(game.ServerStorage:GetChildren()) do 
		
		if string.find(v.Name, string.sub(msg, 6)) ~= nil then
			local msg = Instance.new("Hint",workspace)
			msg.Text = "An admin is changing the map to: "..v.Name..". (Teleport might repeat, also might lag)"
			wait(2)
			local map = v:Clone()
			map.Parent = game.Workspace
		end
			
			for i,v in pairs(game.Players:GetChildren()) do
				v.Character:MoveTo(map.TeleportBase1.Base.Position)
				msg:Destroy()
end
end
end
end
end
end)
end)

So, I have a problem with this map command. On the last few lines of the script, it says at the :MoveTo part, that 'map' is unknown. I tried removing the end, and that worked, but then what would stop the 'for' loop above it?

What should I do?

2 comments

0

From what I see, you have the right number of ends in your script so I presume one of those ends will stop the for loop.

0

Dat tabbing through.

1 answer

use this command: break it will stop a for loop, while true do, ect. Example:

x = 5
while true do
if x = 5 then
print("yay")
elseif x = 1 then
break
end

This discussion is preserved as it was. New answers, comments, and votes are closed.