Ok so i made a map changer script but i cant figure out what the error is what i need to do he is the error 12:17:12.599 - Players.Player1.PlayerGui.InGameGui.Frame.TextBox.LocalScript:20: attempt to index local 'map' (a nil value)
while wait() do
if script.Parent.Parent.Ended.Value == 1 then
for i = 30,0, - 1 do
local Text = script.Parent
local Frame = script.Parent.Parent
Text.Text = i
wait(1)
if i == 0 then
script.Parent.Parent.Ended.Value = 0
spawnmap = game.Workspace.Spawnmap
spawnmap.Value = 1
Text.Visible = false
Frame.TextBox2.Text = "ROUND STARTING"
wait(3)
Text.Visible = false
Frame.TextBox2.Text = "12 HOURS TELL DAY"
local map = game.Workspace:FindFirstChild("Map"..spawnmap.Value)
local target = map.thing.Position
Players = game.Players:GetPlayers()
local player = game.Players.LocalPlayer
Num = Instance.new("IntValue",player)
Num = math.random(1,#Players)
if Num == 1 then
player.PlayerGui.IngameGui.BackGround.Visible = true
end
if player.Shop.Value == 0 then
player.Character:MoveTo(target)
Min = 30
Sec1 = 0
Sec = 0 -- both should start at 0
Text.Text = Min..":"..Sec1..Sec
for i = 600,0,-1 do
wait(1)
print(i)
if i == 600 then
Min = 9
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 540 then
Min = 8
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 480 then
Min = 7
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 420 then
Min = 6
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 360 then
Min = 5
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 300 then
Min = 4
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 240 then
Min = 3
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 180 then
Min = 2
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 120 then
Min = 1
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
elseif i == 60 then
Min = 0
Sec1 = 5
Sec = 9
Text.Text = Min..":"..Sec1..Sec
else
Sec = Sec - 1
if Sec == -1 then
Sec1 = Sec1 - 1
Sec = 9
end
Text.Text = Min..":"..Sec1..Sec
end
end
end
Num:Destroy()
end

2 comments
you haven't defined the variable 'map'
Try using WaitForChild("")