[V2] Moon2Cutscene | Play Moon Animator 2 Files

-- Services
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local CutsceneEvent = ReplicatedStorage:WaitForChild("CutsceneEvent")

local player = game.Players.LocalPlayer

-- Optional: Replace objects with dynamic ones (e.g., player character)
local character = player.Character

-- MoonAnimator2 Module
local moon2Cutscene = require(ReplicatedStorage:WaitForChild("Moon2Cutscene"))

-- Cutscene File and Map (folder with objects)
local file = ReplicatedStorage.Briefing -- Cutscene file
local mapClone = nil -- Placeholder for the cloned map

-- Function to play the cutscene
local function playCutscene(player)
	-- Clone the cutscene folder from ReplicatedStorage to Workspace
	if not mapClone then
		local map = ReplicatedStorage:WaitForChild("Cutscene") -- Folder containing the cutscene objects in ReplicatedStorage
		mapClone = map:Clone() -- Clone it
		mapClone.Parent = workspace -- Set the parent to Workspace
	end

	-- Create the new cutscene instance using the file and the cloned map
	local newCutscene = moon2Cutscene.new(file, mapClone)
	
	local newCutscene = moon2Cutscene.new(file)
	for i,v in newCutscene.file.Items do
		local path = "game"
		for i, n in v.Path.InstanceNames do
			if i == 1 then continue end
			path ..= "."..n
		end

		print(`[{i}] {path}`)
	end
	
	newCutscene:replace(1, game.Workspace.Cutscene.Reggie)
	newCutscene:replace(2, game.Workspace.Cutscene.Kate)
	newCutscene:replace(3, game.Workspace.Cutscene:FindFirstChild("Matt Graver"))
	newCutscene:replace(4, game.Workspace.Cutscene.MissionMan)
	newCutscene:replace(5, game.Workspace.Cutscene.Random)
	newCutscene:replace(6, game.Workspace.CurrentCamera)
	newCutscene:replace(7, game.Workspace.Cutscene.Reggie.Head.Mouth.face2)
	newCutscene:replace(8, game.Workspace.Cutscene.Reggie.Head.Eyes.face)
	newCutscene:replace(9, game.Workspace.Cutscene.Kate.Head.Eyes.face)
	newCutscene:replace(10, game.Workspace.Cutscene.Kate.Head.Mouth.face2)
	newCutscene:replace(11, game.Workspace.Cutscene.Random.Head.Eyes.face)
	newCutscene:replace(12, game.Workspace.Cutscene.Random.Head.Mouth.face2)
	newCutscene:replace(13, game.Workspace.Cutscene.MissionMan.Head.Eyes.face)
	newCutscene:replace(14, game.Workspace.Cutscene.MissionMan.Head.Mouth.face2)
	newCutscene:replace(15, game.Workspace.Cutscene.MattGraver.Head.Eyes.face)
	newCutscene:replace(16, game.Workspace.Cutscene.MattGraver.Head.Mouth.face2)



	
	if character then
		-- Pivot the player to the start CFrame if needed
		-- Replace the first object in the cutscene with the player's character
		newCutscene:replace(1, character)
	end

	-- Ensure all objects are ready
	local canFind, objectMissing = newCutscene:canFindObjects()
	if not canFind then
		warn("Missing object: ", objectMissing)
	end

	-- Wait for all objects to be loaded properly
	newCutscene:waitForObjects()

	-- Play the cutscene
	newCutscene:play()

	-- Optional: Add effects like fade or vignette if desired	F
	local fade = moon2Cutscene.Fade(1, 2, 1)
	fade()
end

-- Event Listener for triggering the cutscene
CutsceneEvent.OnClientEvent:Connect(function(player)
	playCutscene(player)
end)

-- Ensure the script knows the cutscene system is ready
print("Cutscene system initialized.")

I’m still getting the same Warning not error

  10:12:40.655  Missing object:   {
                    ["Path"] =  {
                       ["InstanceNames"] =  {
                          [1] = "game",
                          [2] = "Workspace",
                          [3] = "Reggie"
                       },
                       ["InstanceTypes"] =  {
                          [1] = "DataModel",
                          [2] = "Workspace",
                          [3] = "Model"
                       },
                       ["ItemType"] = "Rig"
                    }
                 }  -  Client - LocalScript:70

^
| That’s the warning I’m getting yet I dont know how to fix it even though I specified it in the local script I have

Would you mind saving your place to a file and sending it?

1 Like

Mission1Test.rbxl (146.6 KB)

here you go.

Mission1Test.rbxl (133.1 KB)
Here you go, the cutscene runs now.

1 Like

oh my god. Wow this is crazy good. Thanks a ton!

1 Like

for effects, would I have to add them within the script or within the moonAnimation I am creating?

like i said before; i published an update adding the bars you suggested and automatically handling the effects so you need only make them in moon animator

1 Like

alright, thanks for the clarifications. I really appreciate it. (Sorry again for many questions)

another question lol mb, is there support for audio? Would I do the same thing for what I did with subtitles by calling the frame and then saying audio:Play()

I also have another question SORRY! so I had a cutscene this time including an object. I did everything everything plays, however only the humanoids move rather than the object I had which was a plane.

doesntowrk.rbxl (1.4 MB)

and for some reason it doesn’t work anymore.

for sounds you can create a task:

local frame = 60
newCutscene.task:register(frame, function()
	sound:Play()
end)

doeswork.rbxl (1.4 MB)
Welding the entire plane to the main part did the trick

On the side note, there were 27 scripts in the plane alone, should probably look at your other models aswell, my plugin offers you a way to easily find all scripts in whatever you select.

1 Like

oh no wonder. Thank you again!

Another suggestion. Adding a skip feature would be super cool.

You can do cutscene:stop() and if necessary, cutscene:reset() or cutscene.map:Destroy()

1 Like

alright thank you so much! :+1:

Missing object:   ▼  {
                    ["Path"] =  ▼  {
                       ["InstanceNames"] =  ▼  {
                          [1] = "game",
                          [2] = "Workspace",
                          [3] = "Part",
                          [4] = "BloodDad"
                       },
                       ["InstanceTypes"] =  ▼  {
                          [1] = "DataModel",
                          [2] = "Workspace",
                          [3] = "Part",
                          [4] = "Decal"
                       },
                       ["ItemType"] = "Decal"
                    }
                 } 

What do I have to do to the decal?

FixWithDecals.rbxl (2.8 MB)

and if you could explain How this is supposed to help me the warning code? I understand that it’s telling me that the decal BloodDad hasn’t been found, but I don’t know the fix.

image
Got this warning when opening the game btw

Also your file contains scripts but they are empty.

Also, just checked your file, the problem is that the Parts name isn’t unique therefore the script cant find it
image

1 Like

oh no wonder. Huh I will need to change those scripts then. Thanks btw!

This module is awesome, I’ve always wanted to bring my animations into real games, and after playing around with it for a while, here’s what I ended up with!
Watch 2024-10-29 02-57-58 | Streamable

4 Likes

Added sound support
and fixed a bug causing :Emit() (aswell as the then non existential method calls) not to work

https://www.youtube.com/watch?v=Ao80CREokvQ how can I be able to make the animation work like this? I’ve tried many things but it doesnt seem to work.