Can't destroy clone

So I’m trying to destroy the gameclone variable which was assigned in the start function, but I keep getting the error “ServerScriptService.game:40: attempt to call missing method ‘Destroy’ of string”
Can someone help me?

local SS = game:GetService("ServerStorage")
local SSS = game:GetService("ServerScriptService")

local round = Rep.round
local minitime = Rep.minitime
local mininame = Rep.mininame
local stat = Rep.gamestatus
local games = SS:WaitForChild("minigames"):GetChildren()

local gameclone = "game"




local function start()
	local mgame = games[math.random(#games)]
	local gameclone = mgame:Clone()
	gameclone.Parent = workspace
	print(mgame)

	minitime.Value = gameclone.Time.Value
	mininame.Value = gameclone.Name


	task.wait(.5)
	for _, plr in pairs(game.Players:GetChildren()) do
		plr.Character.Humanoid.Sit = false
		plr.Team = game.Teams.Playing

		wait(.01)
		plr:LoadCharacter()
	end

	round.Value = true

end

local function stop()
	gameclone:Destroy()
	for _, plr in pairs(game.Players:GetChildren()) do
		plr:LoadCharacter()
	end
	round.Value = false
end

while true do 
	for i = 15, 0, -1 do 
		stat.Value = "Intermission: " .. i
		wait(1)
	end
	start()
	for i = 5, 0, -1 do 
		stat.Value = mininame.Value .. ": " .. i
		wait(1)
	end
	stop()
	if round.Value then
		local team1 = game:GetService("Teams"):FindFirstChild("Playing")
		if team1 then
			local playerCount = #team1:GetPlayers()
			print(playerCount)
			if playerCount == 1 then
				stop()

			end
		else
			print("Team1 not found!")
		end
	end
	wait(1)
end
	local gameclone = mgame:Clone()
	gameclone.Parent = workspace

this could be the reason

  gameclone = mgame:Clone()
  gameclone.Parent = workspace

try this instead

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.