workspace.DescendantAdded doesn't detect characters

I have a module that checks if a descendant is a character. Very simple, but for some odd reason it doesn’t work.

I’ve tried separating the Humanoid. It detects if the descendant is a model but it still fails to find a humanoid. Even with FindFirstChildOfClass.

local function checkIfCharacter(descendant)
	if descendant:IsA("Model") and descendant:FindFirstChild("Humanoid") then
		-- Character
		print(descendant)
	end
end
workspace.DescendantAdded:Connect(checkIfCharacter)

I just pasted this code into a blank game and it printed my character out fine. Is there any more info you can provide?

It’s in the ReplicatedStorage. It still runs because it’s a ModuleScript rather than a LocalScript.

I pasted the code into a Script. It works. However, if I put it in a LocalScript, it doesn’t fire anymore??

Replication time. Just because the client has replicated the character model, does not yet guarantee that it has replicated its descendants. You get away with it on the server, because this latency does not exist, and so the character is typically prepared by the time the connected function is invoked.

3 Likes

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