Hey there! This is actually a pretty old script by me, and immediately its not my best work,
this module is also Clientsided, meaning you can only run it on a local script.
I do have a updated version, although it still isn’t the best its a bit better! (I wrote these all a while ago)
--Services
local RunService = game:GetService("RunService")
--Variables
local Character = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera
local CutsceneHandler = {}
local CutsceneHandler_mt = {__index = CutsceneHandler};
function CutsceneHandler.NewCutscene(AnimationFolder, LengthOfCutScene)
local self = {};
self.Animations = AnimationFolder:WaitForChild("Animations")
self.Characters = AnimationFolder:WaitForChild("Characters")
self.CameraFolder = AnimationFolder:WaitForChild("CameraFolder")
self.Length = LengthOfCutScene
self.LoadedAnimations = {}
for _, Char in ipairs(self.Characters:GetChildren()) do
local Humanoid = Char:FindFirstChild("Humanoid") or Char:FindFirstChild("AnimationController")
for _, Anim in ipairs(self.Animations:GetChildren()) do
if Anim.Name == Char.Name then
table.insert(self.LoadedAnimations, Humanoid:LoadAnimation(Anim))
end
end
end
task.wait(3) --Time to load animations
return setmetatable(self, CutsceneHandler_mt);
end
local function RenderCamera(CameraFolder)
local CinematicsFolder = CameraFolder
local CurrentCameraCFrame = Camera.CFrame
local FrameTime = 0
local Connection
Character.Humanoid.AutoRotate = false
Camera.CameraType = Enum.CameraType.Scriptable
Connection = RunService.RenderStepped:Connect(function(DT)
FrameTime += (DT * 60)
-- This will convert the seconds passed (DT) to the frame of the camera we need.
-- Then it adds it to the total amount of time passed since the animation started
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()
for _, v in ipairs(self.LoadedAnimations) do
v.Looped = false
v:Play()
end
RenderCamera(self.CameraFolder)
if not self.Length then return warn("No Length Specified") end
task.wait(self.Length)
print("Cutscene Complete")
end
return CutsceneHandler
And here is a use example within a localscript
local CutsceneHandlerModule = require(ReplicatedStorage:WaitForChild("CutsceneHandlerModule"))
local Cutscene = CutsceneHandlerModule.NewCutscene(AnimationFolder, LengthOfCutScene -- Optional)
Cutscene:StartCutscene()