It gives me this error " ServerScriptService.Game:41: attempt to index nil with 'Name' " the line that isn't working is this line here 41 or 23 here : Status.Value = ChosenMap.Name.." Chosen"
-- Define Variables
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local MapsFolder = ServerStorage:WaitForChild("Maps")
local Status = ReplicatedStorage:WaitForChild("Status")
local GameLength = 15
local reward = 25
--Game Loop
while true do
Status.Value = "Waiting for enough players"
repeat wait(1) until game.Players.NumPlayers >= 1
Status.Value = "Intermission"
wait(15)
local plrs = {}
for i, player in pairs(game.Players:GetPlayers()) do
if player then
table.insert(plrs,player) -- Add each player into plrs table
end
end
wait(5)
local AvailableMaps = MapsFolder:GetChildren()
local ChosenMap = AvailableMaps[math.random(1, 2)]
Status.Value = ChosenMap.Name.." Chosen"
local ClonedMap = ChosenMap
ClonedMap.Parent = workspace

1 comment
You don't clone the Chosen Map, you must make a pointer to it. You then proceed to shift its location; this will eventually empty the 'MapsFolder'. P.S: 'NumPlayers' is deprecated, pair the length operator with a 'GetPlayers()" return. P.S.S: You should also use the length operator on 'AvailableMaps' to automatically provide the range: AvaliableMaps[math.random(1, #AvaliableMaps)]