Why isn't this a valid child?

so i’ve been working on a animation script, and then a friend ran into this bug.

so, despite the fact that the hold animation is under the script, and it references it as " script.Hold "

it doesn’t work.

so could i get some help cause it’s really annoying and we haven’t found a solution despite trying multiple different things, such as re-exporting, checking the priority of the anim, deleting the animation and then replacing it, and a few other basic things like waitforchild or findfirstchild which also resulted in errors not finding it and saying it’s not an animation object, which is really just confusing.

1 Like

change “Riot Shield” to [“Riot Shield”] maybe?
Could you post your code on line 4…

1 Like

Can you isolate and replicate the problem in a seperate studio client?
Do you or your group own the animation?

Sorry without code or a basic rundown it’s hard to visualize the problem.

1 Like

sorry, here’s all the code:

local Player = game.Players.LocalPlayer
local Char = Player.Character or Player.CharacterAdded:Wait()
local tool = script.Parent
local Anims = {script.Hold}
local LoadedAnims = {}
local animator

	animator = Char:WaitForChild("Humanoid"):WaitForChild("Animator")
	if LoadedAnims[1] == nil then
		LoadedAnims[1] = animator:LoadAnimation(Anims[1])


another thing to note is that yes, whenever he runs it, it is under him and it’s his game so it should work

1 Like

I’m guessing that Hold hasn’t fully loaded in yet so you might want to do script:WaitForChild("Hold").

That yielded indefinetly.
Also @bullettrain5 If you put the animation in the tool, rather than the local script, it should work.
AnimErr.rbxl (32.8 KB)
Check output.

Roblox object hierarchy is strange sometimes. It might have been ignored by the client because it was in a LocalScript inside a Tool. But if it was in a Model like the player model, it works fine. (like some custom character animations) As to why? I have no clue.


1 Like
repeat wait() until script:FindFirstChild("Hold")

NO, don’t do that. That’s a waste and it takes up so much space. Just. NO. Just use :WaitForChild. Never use loops for waiting for something. It’s so inefficient. Use a touched event to fire a bindable event, use Event:Wait(), something else. It’s blatantly inefficient.

1 Like

it doesn’t work, even with waitforchild

I was away sorry.
Did you put the animation in the Tool rather than the Script?
The file i included had a working hierarchy.
Like so:image

yes, that is how it looks now: it does script.Parent.Hold yet it still doesn’t work