-
What do you want to achieve? I want to achieve forcing the map selection to select map.
-
What is the issue? When setting the ForcedMap value to a name of a map, it tries to find the certain map but fails, returning nil.
-
What solutions have you tried so far? I looked in Developer Hub and DevForum but didn’t find anything to solve my problem.
Here’s the code below.
local MapsFolder = game.Lighting.Maps
local Maps = MapsFolder:GetChildren()
local RoundTime = script.RoundTime
local Music = script.Parent.Music
local RemainingTime = script.TimeRemain
local HUDMap = script.CurrentMap
while true do
HUDMap.Value = "loading map"
local ChosenMap = Maps[math.random(1,#Maps)]
if script.ForcedMap.Value ~= "" then
ChosenMap = table.find(Maps, script.ForcedMap.Value) --this i think
script.ForcedMap.Value = ""
end
local MapClone = ChosenMap:Clone()
MapClone.Parent = game:GetService("Workspace")
MapClone:MakeJoints()
for num,player in pairs(game.Players:GetPlayers()) do
player:LoadCharacter()
end
HUDMap.Value = tostring(ChosenMap.Name)
RemainingTime.Value = RoundTime.Value
while RemainingTime.Value >= 0 do
wait(1)
RemainingTime.Value -= 1
end
HUDMap.Value = "loading map"
MapClone:Destroy()
MapClone = nil
end