I Need help creating a cutscene script with character animations like in piggy

Hey guys i need help im trying to know how how to play animations on characters like in Piggy Cutscenes
heres the starting cutscene script local MainCamera = workspace.CurrentCamera
local MyCharacter = game.Players.LocalPlayer.Character
local CameraFolder = game.Workspace.CamFolder

–[[
FUNCTIONS:
]]

function InterpolateCamera(StartCamera, Focus, Duration)–Example: InterpolateCamera(CameraFolder.Cam1, CameraFolder.Cam2, 2)-~-~-~-~First decide your camera, then decide where the camera will look at.
MainCamera.CameraType = Enum.CameraType.Scriptable
MainCamera:Interpolate(StartCamera.CFrame, Focus.CFrame, Duration)
end
local function WriteDialog(object,text)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
wait(0.02)
end
end
function PlayNPCAnimation(Character, AnimationID)–Example: PlayNPCAnimation(game.Workspace.Bob, “rbxassetid://000000”)
for i, v in pairs(Character:GetChildren()) do
if v:IsA(“Humanoid”) then
local Human = v
local AnimationLoaded = v:LoadAnimation(AnimationID)
if Character:FindFirstChild(“HumanoidRootPart”) then
Character.HumanoidRootPart.Anchored = true
else
print(“ERROR: Your character don’t have a HumanoidRootPart! You need to fix it!”)
end
AnimationLoaded:Play()
end
end
end
function SetTalkingCharacter(CharacterName, CharacterColor3fromRGBTextColor)–Example: SetTalkingCharacter(“Bob”, Color3.fromRGB(255, 255, 255))
script.Parent.Parent.CutsceneFrame.CharacterName.Text = CharacterName
script.Parent.Parent.CutsceneFrame.CharacterName.TextColor3 = CharacterColor3fromRGBTextColor
script.Parent.Parent.CutsceneFrame.DialogText.TextColor3 =CharacterColor3fromRGBTextColor
end

function Fade(String_In_Out)–Example: Fade(“In”) [DARK SCREEN] / Fade(“Out”) [FREE SCREEN].
local fadeGui = script.Parent.Parent.FadeFrame
local ts = game:GetService(“TweenService”)
if String_In_Out == “In” then
fadeGui.Visible = true
ts:Create(fadeGui, TweenInfo.new(1), {BackgroundTransparency = 0}):Play()
end
if String_In_Out == “Out” then
fadeGui.Visible = true
ts:Create(fadeGui, TweenInfo.new(1), {BackgroundTransparency = 1}):Play()
end
end

function PlaySound(SoundName, Volume, BoolLoop_True_False)–Example: PlaySound(“Infiltration”, 1, True) [WILL PLAY IN VOLUME 1, AND WILL REPEAT, WARNING: THE THEME HAVE TO BE IN THE “THEMES” FOLDER!!]
local Sound = script.Parent.Parent.Themes:FindFirstChild(SoundName)
Sound.Volume = Volume
if BoolLoop_True_False == true then
Sound.Looped = true
else
Sound.Looped = false
end
Sound:Play()
end
function StopSound(SoundName, StringTweenType)–Example: StopSound(“Infiltration”, “Tweening”)[WILL STOP THE SOUND BY TWEENING] or StopSound(“Infiltration”, “JustStop”)[WILL STOP THE SOUND IMMEDIATELY]
local sound = script.Parent.Parent.Themes:FindFirstChild(SoundName)
if StringTweenType == “Tweening” then
local ts = game:GetService(“TweenService”)
ts:Create(sound, TweenInfo.new(5), {Volume = 0}):Play()
end
if StringTweenType == “JustStop” then
sound:Stop()
end

end
local MyEvent = game.ReplicatedStorage.CutscenesRemotes.StartCutscene–Set the remote event for the cutscene start.

function PlayCutscene()
MyCharacter.Head.CFrame = CFrame.new(0,0,0)–Change the position that the character will teleport to!
local dtext = script.Parent.Parent.CutsceneFrame.DialogText
script.Parent.Parent.FadeFrame.BackgroundTransparency = 0
wait(2)
script.Parent.Parent.CutsceneFrame.Visible = true
PlaySound(“Infiltration”, 1, true)
Fade(“Out”)
InterpolateCamera(CameraFolder.Cam1, CameraFolder.Cam2, 1)
SetTalkingCharacter(“Player”, Color3.fromRGB(255, 255, 255))
WriteDialog(dtext, “Huh Where am I?”)
wait(4)
InterpolateCamera(CameraFolder.Cam3, CameraFolder.Cam2, 3)
WriteDialog(dtext, “This is not where the PlaneCrash ta al…”)
wait(4)
SetTalkingCharacter(“Polly”, Color3.fromRGB(204, 136, 204))
WriteDialog(dtext, “Look Your Finally awake Player An infected Broke into The building And Has Attacked 3 of Our Members Think you can help get our stuff and get here so i can look the place?”)

wait(4)
WriteDialog(dtext, "It Would Save 4 of our members They are stuck in rooms They are counting on you")
wait(3)
InterpolateCamera(CameraFolder.Cam1, CameraFolder.Cam2, 2)
SetTalkingCharacter("Player", Color3.fromRGB(255, 255, 255))
WriteDialog(dtext, "Ok Looks Like im Going in What could Go wrong....")
wait(2)
StopSound("Infiltration", "Tweening")
Fade("In")
script.Parent.Parent.CutsceneFrame.Visible = false
wait(2)
Fade("Out")
MainCamera.CameraType = Enum.CameraType.Custom
MainCamera.CameraSubject = MyCharacter.Humanoid

end

MyEvent.OnClientEvent:Connect(PlayCutscene)
I dont know where to put or what to write ive tried using The load anim animation id and animation:Play script but that doesnt work can someone help me out plz

1 Like

guys is anyone here i need help

Hello, if you are trying to load an animation are you loading it to the humanoid. I’m pretty sure you have to use animation controller under humanoid now

1 Like

ok how would i do that
can you give me a tutorial plz

so what place do i put the bottom script at
workspace
starter Gui
Sever script service

do an Instance.new(“Animator”) and parent it to Humanoid

 local function playAnimationFromServer(character, animation)
      local humanoid = character:FindFirstChildOfClass("Humanoid")
      if humanoid then
      -- need to use animation object for server access
      local animator = humanoid:FindFirstChildOfClass("Animator")
      if animator then
      local animationTrack = animator:LoadAnimation(animation)
      animationTrack:Play()
      return animationTrack
      end
   end
end

-- call the function when you want to play animation
--playAnimationFromServer(playercharacter, animation)

I’m pretty sure humanoid already has an animator in its descendants

not sure since I just did this:

if Humanoid:FindFirstChildOfClass("Animator") then
		print("FOUND")
end

and it didn’t print

? I have never put the animator in since it arrived and it seems to be there for me

can u share a sample file cause i never seen it as a descendant

I put this in a local script and a script in starter character and it worked

wait(1)
print(script.Parent.Humanoid.Animator)

weird I get it to print but when I try to assign a local variable == to it, it says it doesn’t exist

edit nvm it doesn’t even print, i think I was printing my instance.new()

idk whats up but ill stick to just instance.new’ing it

	Animation.Parent = Humanoid
	print(Humanoid.Animator)
	local Animator = Humanoid.Animator
	

Where are you defining Humanoid?

it was merely a snippet of code, I go through a for loop of npcs to get humanoid so:

local Humanoid = v:FindFirstChildOfClass("Humanoid")

humanoid is not incorrect as the animations function for all npcs

I am so sorry. I forgot they were npcs and not players. I think you might have to add an animator to the humanoid

1 Like

well ill keep it in mind for player animations

2 Likes

Do i Put in the humainoid in the character

do i put that script in the humanoid

do i put it in humanoid
of the character