Minigame choosing randomly despawns

Hi!
Recently, me and my group have been working on a Minigames title. This ModuleScript handles the games, ofc. For some reason, it will randomly despawn it. What have I done wrong?

the code | it's really long, so im hiding it to make it look cleaner
local module = {}

local AlivePlayers = {}

local MiniGames = {"4Blocks","6Blocks"}

local MapStars = {
	["4Blocks"] = 4, -- Amount
	["6Blocks"] = 2,
}

function module.Stars(Map)
	for i, Star in pairs(MapStars) do
		return MapStars
	end
end

function module.ChooseMiniGame()
	local RandomGame = MiniGames[math.random(1, #MiniGames)]
	if RandomGame then
		if RandomGame == "4Blocks" then
			module.Start4Blocks(RandomGame)
		elseif RandomGame == "6Blocks" then
			module.Start6Blocks(RandomGame)
		end
		return RandomGame
	end
end

function module.DeSpawnBlocks(Event)
	local EventFolder = game.Workspace:FindFirstChild("EventFolder")
	if EventFolder then
		EventFolder:Destroy()
	end
end

function module.SpawnBlocks(Event)
	module.DeSpawnBlocks()
	wait(4)
	local EventFolder = game.ReplicatedStorage:FindFirstChild(Event):Clone()
	EventFolder.Parent = workspace
	EventFolder.Name = "EventFolder"
	
end

function module.Start4Blocks(GameName)
	module.SpawnBlocks(GameName)
	for i, player in pairs(game.Players:GetPlayers()) do
		local HumaniodRootPart = player.Character:FindFirstChild("HumanoidRootPart")
		if HumaniodRootPart then
			HumaniodRootPart.Anchored = true
			HumaniodRootPart.CFrame = CFrame.new(game.Workspace:FindFirstChild("EventFolder"):FindFirstChild("MiddilePart").Position) + Vector3.new(0,10,0)
			wait(1.05)
			HumaniodRootPart.Anchored = false
		else
			local Torso = player.Character:FindFirstChild("Torso")
			if Torso then
				Torso.Anchored = true
				Torso.CFrame = CFrame.new(game.Workspace:FindFirstChild("EventFolder"):FindFirstChild("MiddilePart").Position) + Vector3.new(0,10,0)
				wait(1.05)
				Torso.Anchored = false
			end
		end
	end
end

function module.Start6Blocks()

end

function module.EndRound()
	
end

function module.RemovePlayer(player)
	if AlivePlayers[player] then
		table.remove(AlivePlayers,player)
		AlivePlayers[player] = nil
	end
end

function module.AddPlayer(player)
	table.insert(AlivePlayers,player)
	print("Working")
end

return module

1 Like

So, this is what’s REALLY happening:
It’s working, but it is for some reason re choosing the minigame over and over, which makes it despawn.
I can tell that because the text changes to “6Blocks” and then after a bit despawns.

This is a big issue which we need to fix asap

1 Like

Is anybody going to help here? This is a major problem that needs to be addressed.

can you check the output and tell me if there is an error?, i’ll see what i can do.

Nope no errors. (I working with him on the game)

My only guess the problem is

function module.SpawnBlocks(Event)
	module.DeSpawnBlocks()
	wait(4)
	local EventFolder = game.ReplicatedStorage:FindFirstChild(Event):Clone()
	EventFolder.Parent = workspace
	EventFolder.Name = "EventFolder"
	
end

yeah when i ran it i found nothing, it seems that it’s not an error and just that you past over something, please try and see if you could try and modify the scripts that despawn or spawn blocks.

can you look in my main script then?


Found a new problem. It’s not cloning into wrkspace

that’s your issue then, it seems it can’t clone. could I see the cloning parts?

image

could i see the cloning part script as well?

function module.SpawnBlocks(Event)
	module.DeSpawnBlocks()
	wait(4)
	local EventFolder = game.ReplicatedStorage:FindFirstChild(Event):Clone()
	EventFolder.Parent = workspace
	EventFolder.Name = "EventFolder"

end

hmm, could you try and swap the .name and .parent?

there, it needs a position, could you try setting it to a certain position?

it should snap to “loadBlock1”

im dumb i forgot to change it lol
image

there!, does it work now? it seemed that the position didn’t match to your newest block.