Hey there! Today I made a Cutscene Module for roblox Moon Animator. I plan to make it open source after I add other features such as effects, but currently I just have this.
local CutsceneHandler = {}
local RunService = game:GetService("RunService")
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Camera = workspace.Camera
function CutsceneHandler.NewCutscene(AnimationFolder)
local Animations = AnimationFolder:WaitForChild("Animations"):GetChildren()
local Characters = AnimationFolder:WaitForChild("Characters"):GetChildren()
local CameraFolder = AnimationFolder:WaitForChild("CameraFolder")
if not AnimationFolder or not Characters or not CameraFolder then
warn("Could not find folder")
return
end
local LoadedAnimations = {}
for _, Char in ipairs(Characters) do
local Humanoid = Char:FindFirstChild("Humanoid")
for _, Anim in ipairs(Animations) do
if Anim.Name == Char.Name then
table.insert(LoadedAnimations, Humanoid:LoadAnimation(Anim))
end
end
end
return LoadedAnimations, CameraFolder
end
function Cinematic(CameraFolder)
local CinematicsFolder = CameraFolder
local CurrentCameraCFrame = workspace.CurrentCamera.CFrame
local FrameTime = 0
local Connection
Character.Humanoid.AutoRotate = false
Camera.CameraType = Enum.CameraType.Scriptable
Connection = RunService.RenderStepped:Connect(function(DT)
FrameTime += (DT * 60)
local NeededFrame = CinematicsFolder.Frames:FindFirstChild(tonumber(math.ceil(FrameTime)))
if NeededFrame then
Camera.CFrame = NeededFrame.Value
else
Connection:Disconnect()
Character.Humanoid.AutoRotate = true
Camera.CameraType = Enum.CameraType.Custom
Camera.CFrame = CurrentCameraCFrame
end
end)
end
function CutsceneHandler.StartCutscene(LoadedAnimations, CameraFolder, LengthOfCutscene)
for _, v in ipairs(LoadedAnimations) do
v.Looped = false
v:Play()
end
Cinematic(CameraFolder)
if not LengthOfCutscene then return warn("No Length Specified") end
task.wait(LengthOfCutscene)
print("Cutscene Complete")
end
return CutsceneHandler
Heres the folder for it.