Coroutine Crashes Entire Game - Need Help

I’m trying to make a coroutine run a repeated function that cycles cutscenes in my core game, while also executing the title screen intro.

However, no matter what I try, it’s always this line that breaks not only the script, but kills the entire game. No matter where in the script I put it, my game becomes completely nonfunctional when it is present. (No scripts run, no audio plays, nothing in output.) (Below)

local lol = coroutine.create(CycleCutscenes())

These are the contents of the CycleCutscenes() function:

local CycleCutscenes = function()
	repeat
		CutsceneService.CreateCutscene(CutscenePositions.Core1, CutscenePositions.Core2, 40, 40, 14, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
		wait(10)
		CutsceneService.CreateCutscene(CutscenePositions.Coolant1, CutscenePositions.Coolant2, 40, 40, 14, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
		wait(10)
		CutsceneService.CreateCutscene(CutscenePositions.ControlRoom1, CutscenePositions.ControlRoom2, 45, 45, 14, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
		wait(10)
	until IsItPressed == true
end

CutsceneService is a simple custom ModuleScript I made that allows for cutscenes to be created without a plugin. IsItPressed is a variable that looks for when the play button is pressed. It would usually avert the loop and put the player in game. But, like I said before,

However, no matter what I try, it’s always this line that breaks not only the script, but kills the entire game.

Also, if I should mention this, everything is run inside a LocalScript.

If anyone needs the full script, let me know. I really need some help here. I’ve never been really experienced with coroutines and have never been able to successfully use them.

1 Like

could you also provide the full script that the coroutine is created in and the CutsceneService.CreateCutscene() function?

2 Likes

coroutine.create expects a function, so what you should do is:

local lol = coroutine.create(CycleCutscenes)
coroutine.resume(lol)

or use coroutine.wrap to get a function which you can then call to start the coroutine

coroutine.wrap(CycleCutscenes)()
1 Like

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