Child Added Problem

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    I want to get the added child from a Folder by using the event “ChildAdded” in a local script so i can animate it

  2. What is the issue? Include screenshots / videos if possible!

I get the Object with “ChildAdded” but when i want to get the humanoid or other Children of the Object it says that those aren’t valid members of the Object

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I’ve been looking for solutions but i couldnt find anything

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

The child I want to get is created by the server. When the server prints the number of the children of the Object I get the correct number but when the client prints it i get 0

I am not the best at english but I hope u can understand my problem :smile:

Here’s how my local script goes like


local function AnimateObject(Object)

local Animator = Object.Humanoid:FindFirstChild("Animator") or Object.AnimationController:FindFirstChild("Animator")

if not Animator then
local Animator = Instance.new("Animator", Object.Humanoid)

local Track = Animator:LoadAnimation(Object.IdleAnim)
Track:Play()

end


end

workspace.Folder.ChildAdded:Connect(AnimateObject)

The child added is not guaranteed to have a member named Huamnoid or AnimationController. You need to use FindFirstChild for that as well.

But if i use FindFirstChild it will be nil. The added Child has no children in the local script for some reason.

use WaitForChild. Children from server dont replicate instantly and you have to wait for them to load.

1 Like

TYSM, THIS WILL HELP ME SM THANKS!!! :smile:

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.