I have this round system for my new game and I dont know whats wrong.
Did roblox remove :Clone()?
Heres what I have
`local players = {}
local maps = {}
local ElevatorSongs = {}
local MapInProgress = false
local MapRemoved = true
local Waiting = true
local ElevatorPart = game.Workspace.Special.ElevatorPad
local Intermission = 30
local IntermissionQueued = false
local RunService = game:GetService(“RunService”)
game.Workspace.Special.Queue.Touched:Connect(function(hit)
if game.Players:GetPlayerFromCharacter(hit.Parent) then
local p = game.Players:GetPlayerFromCharacter(hit.Parent)
addToQueue(p)
end
end)
function ReturnPlayers(p) – Returns an array of the players and gets them back in the elevator
if table.find(players, p.Name) and p.Character:FindFirstChild(“Torso”) then
p.Character.Torso.CFrame = ElevatorPart.CFrame
end
end
function IsArrayEmpty()
local hasRecord = false
for , in pairs(maps) do
hasRecord = true
break
end
return hasRecord
end
function ArePlayersInQueue(p) – Check if the table is empty
local hasRecord = false
for , in pairs(players) do
hasRecord = true
break
end
return hasRecord
end
function PayoutPlayers(p) – Function to give cash to players who survived a room
if table.find(players, p.Name) then
local cash = game.Players:FindFirstChild(p.Name).Currency.Money
cash.Value = cash.Value + 1
end
end
function GetQueue()
for i,p in pairs(game.Players:GetDescendants()) do
if table.find(players, p.Name) then
return p
end
end
end
function addToQueue(p) – Add a player to the queue on queued
if table.find(players, p.Name) then
wait()
else
table.insert(players, p.Name)
end
end
function LoadMap(map, p, id) – Function to load the map
MapInProgress = true
Waiting = false
print(id, map, p.Name)
local mapchoosen = map:Clone();
mapchoosen.Parent = workspace;
game.ReplicatedStorage.PlaySong:FireClient(p, id) – Map song
wait(mapchoosen.Duration.Value)
id = ElevatorSongs[math.random(#ElevatorSongs)]
game.ReplicatedStorage.PlaySong:FireClient(p, id) – Elevator Song
print(“Removed map”)
mapchoosen:Remove()
Waiting = true
MapRemoved = true
MapInProgress = false
end
function GetMap()
for i,v in pairs(game.ServerStorage.Maps:GetDescendants()) do
print(v)
if v:IsA(“Folder”) and v:FindFirstChild(“Duration”) and v:FindFirstChild(“Song”) and not MapInProgress and Waiting and MapRemoved and not IsArrayEmpty() then
print(“No Maps Found”)
table.insert(maps, v.Name) – Inserts the maps
print(“Inserted Maps”)
local map = maps[math.random(#maps)] – gets a random map
table.remove(maps, table.find(maps, map)) – removes the chosen map
print("Map = "…map)
LoadMap(map, GetQueue(), v:FindFirstChild(“Song”).Value)
print(“Got map”)
elseif IsArrayEmpty() and v:IsA(“Folder”) and v:FindFirstChild(“Duration”) and v:FindFirstChild(“Song”) and not MapInProgress and Waiting and MapRemoved then
print(“Not an empty Array”)
local map = maps[math.random(#maps)] – gets a random map
table.remove(maps, table.find(maps, map)) – removes the chosen map
LoadMap(map, GetQueue())
print(“Got Map without insertion”)
end
end
end
game.Players.PlayerAdded:Connect(function(p)
p.CharacterAdded:Connect(function(c)
c:WaitForChild(“Humanoid”).Died:Connect(function()
if table.find(players, p.Name) then
local id = 2111554126 – Lobby Song
table.remove(players, table.find(players, p.Name)) – Remove Players On Death
game.ReplicatedStorage.PlaySong:FireClient(p, id)
end
end)
end)
end)
game.Players.PlayerRemoving:Connect(function(p) – Remove Players if removed from game
if table.find(players, p.Name) then
table.remove(players, table.find(players, p.Name))
end
end)
– Round System –
RunService.Heartbeat:Connect(function(step)
wait()
if ArePlayersInQueue() and not Waiting then – Function to start the round
for i,p in pairs(game.Players:GetDescendants()) do
if table.find(players, p.Name) then – Checks for players in the queue
ReturnPlayers(p) – Get Players Back inside
PayoutPlayers(p)
IntermissionQueued = false
end
end
elseif not IntermissionQueued and ArePlayersInQueue() and Waiting then
IntermissionQueued = true
Waiting = true
print(“Intermission Queued”)
wait(1) – change to intermission
GetMap()
print(“Got Map”)
end
end)`