Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

[EDITED] AnimationController object isn't a descendant of the game object?

Asked by 4 years ago
Edited 4 years ago

When the player dies, the script says that the AnimController is not a child of the ViewModel. I dont know why, but here is my error, local script, and module script.

NOTE: the error occurs in the module script

ERROR HERE 17:22:06.288 - LoadAnimation requires the AnimationController object (VM_PLR.A_CT) to be a descendant of the game object

LOCAL SCRIPT HERE

01local AnimService = require(game.ReplicatedStorage.ModuleScripts.LoadAnimService)
02 
03game.ReplicatedStorage.Events.BindableEvents.PlayerPressedPlay.Event:Connect(function(GunsRequested, GunsRequestedPos)
04    local VM = game.ReplicatedStorage.VM_PLR:Clone()
05    local fol = Instance.new("Folder", workspace.PlrVM)
06    VM.Parent = fol
07    local char, plr = game.Players.LocalPlayer.Character, game.Players.LocalPlayer
08    fol.Name = plr.Name
09    local hum = VM.A_CT
10    local c = false
11    for i, v in pairs(hum:GetChildren()) do
12        if v:IsA("Animator") then
13            c = true
14            break
15        end
View all 42 lines...

MODULE SCRIPT HERE

01local module = {}
02 
03function module:LoadAnimTable(tab, hum)
04    local ANIMATABLE = {}
05    local ANIMATABLEPOS = {}
06    for i, v in pairs(tab) do
07        table.insert(ANIMATABLE, 1, hum:LoadAnimation(v))
08        table.insert(ANIMATABLEPOS, 1, v.Name)
09    end
10    return ANIMATABLE, ANIMATABLEPOS
11end
12 
13function module:DecodeAnimTable(animtable, animtablepos, returnval)
14    local counter = 1
15    local result = nil
View all 32 lines...

2 answers

Log in to vote
1
Answered by 4 years ago

It looks like you have a problem playing animations when the viewmodel is set to nil.

Basically, the error is saying the viewmodel has to be in workspace to play the animation. The problem is, you're setting the model's parent to nil. Here's a way you might be able to solve that.

01local dead = false
02 
03game.Players.LocalPlayer.Character.Humanoid.Died:Connect(function()
04    dead = true
05    viewmodel.Parent = nil
06end)
07 
08--//When you're about to play animations do:
09 
10if dead == false then --//If we're not dead
11    anim:Play() -- play
12else --//If we're ded
13    print("player is ded")
14    delay(2, function() -- Set dead back to false after a bit.
15        dead = false
16    end)
17end

I'm pretty sure this isn't the best way to solve it, but it does the job.

Let me know if you have any issues, questions or concerns.

Cheers, Zander

0
Thanks for the help! Although, I forgot to mention that the error occurs on the module script, which hum:LoadAnimation(v) fails to work. Thank you for helping at least. rookiecookie153 53 — 4y
Ad
Log in to vote
0
Answered by 4 years ago

YES YES YES YES! THE SOLUTION IS TO RESET YOUR SCRIPTS WHEN YOU DIE!!!!

Answer this question