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

Why wont this Map Changing Script Work? (I am new)

script.Parent.Touched:connect(function()
				wait(1)
	for i,v in pairs(game.ServerStorage:GetChildren()) do
			if string.lower(v.Name) == "level2" then
	v.Parent = Workspace
	end
end
for i,v in pairs(game.Workspace:GetChildren()) do
if string.lower(v.Name) == "level1" then
	v.Parent = ServerStorage
					end
		   end
end)

This is suppose to change the map when the brick is touched but wont work..

2 answers

See what prints.

local db = true
local map1 = "level1"
local map2 = "level2"
local storage = game:GetService("ServerStorage")

if storage:findFirstChild(map1) and  storage:findFirstChild(map2) then 
	print("Both are there")
else
	print("One or both of those is nil")
	return 
end



script.Parent.Touched:connect(function(hit)
	if hit.Parent and game.Players:GetPlayerFromCharacter(hit.Parent) and db then
		db = false
		for i,v in pairs(storage:GetChildren()) do
			if v.Name:lower() == map2 then
				v.Parent = Workspace
			end
		end
		for i,v in pairs(Workspace:GetChildren()) do
			if v.Name:lower() == map1 then
				v.Parent = storage -- You had an error here.
			end
		end
		db = true
	end
end)




Did you check the output window?

4 comments

0

Yup

0

Did you create a map? Does the script even say about changing maps?

0

Yes I created a map

0

Poor use of an answer.

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