Hi everyone. I've been having an issue with the :Destroy() function which won't allow me to destroy any models.
I've been attempting to create a battle-royale style game and the main game script is supposed to remove the map after the game has finished by using the :Destroy() function, however once the game finishes the output throws out the error "Unable to :Destroy() Terrain". In an attempt to solve this, i've completely ungrouped and regroup the entire terrain model with no success, and i'm not quite sure as to what to do next. Any help is greatly appreciated.
CODE:
local s = script.Stat
local vals = game.ReplicatedStorage.vals
t = 0
while true do
local plrs = game.Players:GetChildren()
if #plrs >0 then
t = 15
repeat
t = t-1
s.Value = "Intermission... "..t
wait(1)
until t==0
s.Value = "Game Starting!"
wait(2)
local mapselect = game.ReplicatedStorage.Games:GetChildren()
local choose = math.random(1,#mapselect)
curnum = 0
for i =1,#mapselect do
curnum = curnum +1
if curnum == choose then
mapselect[i]:Clone().Parent = workspace
curmap = mapselect[i].Name
end
end
wait(3)
local plrs = game.Players:GetChildren()
for i = 1,#plrs do
local num = math.random(1,3)
plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position)
plrs[i].Character.Parent = workspace.Ingame
end
t=300
repeat
t = t-1
s.Value = t.." seconds left!"
wait(1)
local ingame = workspace.Ingame:GetChildren()
until t ==0 or vals.Winner.Value ~= "" or #ingame == 0
if vals.Winner.Value ~= "" then
s.Value = vals.Winner.Value.. " has won!"
workspace[curmap]:Destroy()
game.Players[vals.Winner.Value].leaderstats.Points.Value =game.Players[vals.Winner.Value].leaderstats.Points.Value +50
game.Players[vals.Winner.Value].leaderstats.Wins.Value =game.Players[vals.Winner.Value].leaderstats.Wins.Value +1
vals.Winner.Value = ""
else
s.Value = "No one has won!"
end
workspace[curmap]:Destroy()
wait(3)
local ingame = workspace.Ingame:GetChildren()
for i =1,#ingame do
local plr = game.Players:GetPlayerFromCharacter(ingame[i])
plr:LoadCharacter()
end
else
s.Value = "Two or more players are needed to play!"
wait(1)
end
end

2 comments
If you've named your map "Terrain", then you're going to have conflicts with the object used for ROBLOX's actual terrain system, which cannot be destroyed.
Ahh, THAT'S what it was! Thanks so much!