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