I want to load animation into an object value, so that I can use it anywhere later, I think it’s very convenient, but for some reason the script gives an error
LoadAnimation to object value
do
dummyHRP = dummy:WaitForChild(“HumanoidRootPart”)
dummyHum = dummy:WaitForChild(“Humanoid”)
local run = dummy:WaitForChild(“Run”)
local kick = dummy:WaitForChild(“Kick”)dummy.Parent = workspace.NPC.Zombie
dummy.RunAnim.Value = dummyHum:LoadAnimation(run)
dummy.KickAnim.Value = dummyHum:LoadAnimation(kick)
dummy.KickAnim.Value:Play()
dummy.RunAnim.Value:Play()
end
Then in other script Run this
while true do
--print( dummys)
local dumHum = dummy:FindFirstChild("Humanoid")
local dumHRP = dummy:FindFirstChild("HumanoidRootPart")
local pathParts = dummy:FindFirstChild("PathParts")
if dumHum and dumHRP and girlHRP then
--dumHum:MoveTo(girlHRP.Position)
local closestChr = funcMod.getClosestChrPos(dumHRP.Position)
if closestChr then
if dummy.Name == "ZombieZ" then
if (dumHRP.Position - closestChr.HumanoidRootPart.Position).Magnitude < 15 then
--print(111)
local soundZombie = dumHRP:FindFirstChild("SoundZombie")
if soundZombie then
if not soundZombie.IsPlaying then
soundZombie:Play()
end
end
dummy.RunAnim.Value:Stop()
dummy.KickAnim.Value:Play()
task.wait(2)
dummy.KickAnim.Value:Stop()
dummy.RunAnim.Value:Play()
Get error
ServerScriptService.Main:85: attempt to index nil with ‘Play’
how this objValue can be nill ? dummy.KickAnim.Value