So Im having issues about the Animator not working properly on a Npc, the Animator somehow doesnt play the animations I want and this is bugging me, nothing works!
I’ve tryed putting the script lines on a “script”, “Local script”, looked trough the roblox forum (and the recent change on the animator), i used the original animation script from the Lua Developer.
This script I putted is the Local Script that i putted in the player’s character to manage mine Npc, and i cutted half of it to resume the problem im having (And if there are more end
's or lines than it appears, dont care about that)
The problem is indicated on the line marked with a “1”
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local CutsceneGui = PlayerGui:WaitForChild("CutsceneGui")
local Frame = CutsceneGui.Frame
local TextBox = Frame:FindFirstChild("WriteOn")
local CutscenePreps = require(script:WaitForChild("CutscenePreps"))
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local CtscnReceiver = ReplicatedStorage:WaitForChild("CtscnReceiver")
local CtscnSender = ReplicatedStorage:WaitForChild("CtscnSender")
local GameNpcs = workspace:WaitForChild("GameCharacters")
local Npc1 = GameNpcs:FindFirstChild("Npc1")
local Npc2 = GameNpcs:FindFirstChild("Npc2")
local Npc1Files = script.Parent:WaitForChild("ForNpc1")
local Npc2Files = script.Parent:WaitForChild("ForNpc2")
local PlayerFiles = script.Parent:WaitForChild("ForPlayer")
local CameraTweening = false
local Finished = false
local Running = false
local function WhenRequested(player, Files, CameraCframes)
if not Running then
Running = true
Finished = false
local Number = 1
local ChosenAnimation1
local ChosenAnimation2
local ChosenAnimationPlayer
local ChosenLinePlayer
local CurrentCmrCframe
local ChosenLine1
local ChosenLine2
local TimePlayed1
local TimePlayed2
local TimePlayedPlayer
local WaitTime1
local WaitTime2
local WaitTimePlayer
while not Finished do
wait(1)
local CharactersAnmQuantity = {Files.Npc1Animations:GetChildren(), Files.Npc2Animations:GetChildren(), Files.PlayerAnimations:GetChildren()}
local CharactersLineQuantity = {Files.Npc1Lines, Files.Npc2Lines, Files.PlayerLines}
while not (Number >= #CharactersAnmQuantity) and not (Number >= #CharactersLineQuantity) do
ChosenAnimation1 = Files.Npc1Animations[Number]
ChosenAnimation2 = Files.Npc2Animations[Number]
ChosenLine1 = Files.Npc1Lines[Number]
ChosenLine2 = Files.Npc2Lines[Number]
ChosenAnimationPlayer = Files.PlayerAnimations[Number]
ChosenLinePlayer = Files.PlayerLines[Number]
CurrentCmrCframe = Files.CameraCframes[Number]
TimePlayed1 = Files.Npc1TextFiles:FindFirstChild(Number)
TimePlayed2 = Files.Npc2TextFiles:FindFirstChild(Number)
TimePlayedPlayer = Files.PlayerTextFiles:FindFirstChild(Number)
WaitTime1 = TimePlayed1:FindFirstChild("WaitTime")
WaitTime2 = TimePlayed2:FindFirstChild("WaitTime")
WaitTimePlayer = TimePlayedPlayer:FindFirstChild("WaitTime")
Files.Npc1Animations:SetAttribute(ChosenAnimation1)
Files.Npc2Animations:SetAttribute(ChosenAnimation2)
Files.PlayerAnimations:SetAttribute(ChosenAnimationPlayer)
local Humanoid1 = Npc1:FindFirstChild("Humanoid")
local Animator1 = Instance.new("Animator", Humanoid1)
1 if tonumber(ChosenAnimation1.Name) == Number then
local Load = Animator1:LoadAnimation(ChosenAnimation1)
Load.Priority = Enum.AnimationPriority.Core
Load:Play()
if tonumber(ChosenLine1.Name) == Number then
repeat
wait(0.1)
until ChosenAnimation1.TimePosition == TimePlayed1
if ChosenAnimation1.TimePosition == TimePlayed1 then
CutscenePreps.PlayLines(ChosenLine1, WaitTime1)
end
end
Number = Number + 1
end
Running = false
end
end