local RS = game.ReplicatedStorage
local Maps = RS.Maps
local CountDownTime = 5 --Time until a round starts
local RoundEndTime = 5 -- Time for a round
local TimeValue = script.TimeValue
local Mapstoload = Maps:GetChildren()
function roundIntermission()
TimeValue.Value = CountDownTime
for count = 1,CountDownTime do
TimeValue.Value = TimeValue.Value - 1
wait(1)
end
end
function getRandomMap()
local randomMap = Mapstoload[math.random(1, #Mapstoload)]
randomMap.Parent = game.Workspace
end
function RemoveMap()
randomMap.Parent = RS
end
function roundTime()
TimeValue.Value = RoundEndTime
for count2 = 1, RoundEndTime do
TimeValue.Value = TimeValue.Value - 1
wait(1)
end
end
while wait() do
roundIntermission()
getRandomMap()
roundTime()
RemoveMap()
end
You cannot have a variable being made in a function and being reused in another. I would recommend calling the “randomMap” value outside of the function to make it globally and then inside the function you can give the variable a value. I hope this helped!
local RS = game.ReplicatedStorage
local Maps = RS.Maps
local CountDownTime = 5 --Time until a round starts
local RoundEndTime = 5 -- Time for a round
local TimeValue = script.TimeValue
local Mapstoload = Maps:GetChildren()
local randomMap
function roundIntermission()
TimeValue.Value = CountDownTime
for count = 1,CountDownTime do
TimeValue.Value = TimeValue.Value - 1
wait(1)
end
end
function getRandomMap()
randomMap = Mapstoload[math.random(1, #Mapstoload)]
randomMap.Parent = game.Workspace
end
function RemoveMap()
randomMap.Parent = RS
end
function roundTime()
TimeValue.Value = RoundEndTime
for count2 = 1, RoundEndTime do
TimeValue.Value = TimeValue.Value - 1
wait(1)
end
end
while wait() do
roundIntermission()
getRandomMap()
roundTime()
RemoveMap()
end