The DescendantAdded function doesn't run (it doesn't print anything)

workspace.Nods.DescendantAdded:Connect(function(nod)
    print(nod)
    if nod:IsA("BasePart") and NodRelatedStorage:FindFirstChild(nod.Name) then
        print(nod)
        local Nod_Durability = nod:GetAttribute("Durability")
        local HealthBar = nod:FindFirstChild("HealthBar"):FindFirstChild("Background"):FindFirstChild("Durability")
    end
end)

this function doesnt launch for some reason (it doesnt print anything)

I try to detect when an Instance gets added to those folders (with the red arrows)
image

ITS A SERVER SCRIPT BTW
Thank you

Where is the script located? Is it in a place that server scripts can run?

its inside serverscriptservice

Interesting, just out of curiosity if you instead use one of the folders instead of the Nods folder does anything print?

like the Common_Nods, etc. folders? like DescendantAdded and print what gets added inside?

Yes, exactly like that. I am aware it’s not what your going for but I am just curious to see if it’ll print anything

--Nod Health Bar
workspace.Nods.Common_Nods.DescendantAdded:Connect(function(nod)
	print(nod)
	if nod:IsA("BasePart") and NodRelatedStorage:FindFirstChild(nod.Name) then
		print(nod)
		local Nod_Durability = nod:GetAttribute("Durability")
		local HealthBar = nod:FindFirstChild("HealthBar"):FindFirstChild("Background"):FindFirstChild("Durability")
	end
end)
``` I did this
It should print since there are nods are getting added to the folder, but doesnt print anything

image
as you see here, theres a CommonNod but it doesnt print anything

First things first, you wanna make sure the function is being connected, use a print to check.

workspace.Nods.DescendantAdded:Connect(function(nod)
    print(nod)
end)
print("connected")

are you sure a folder is being added inside Nods?

That doesn’t say if it’s connected, use this to know if it connects:

local connection = workspace.Nods.DescendantAdded:Connect(function(nod)
    print(nod)
end)
print("Status: "..(connection and "Connected" or "Failed to connect"))

Are you sure the nod is being added using a serverscript and not local?

1 Like

image

I was about to ask the same thing.

@woitur are the Nods being added through a local or server script, if they are added through a local script then the server doesn’t see the nod’s so the function doesn’t fire.

This seems to be the only reason this would happen

Ok, but are the nods being ADDED in that script or another script.

they are being added to the folder inside the same script (2 different blocks of code) which is a server script

1 Like

image
thats the same script in which I have my Nod Health Bar (the function that doesnt run)

2 Likes

And the nods do actually appear in your folder, its just that its not being detected?

What if you put a script on the Nod that detected a change in its parent and worked from there?

1 Like

or try moving the script out of SSService and into workspace

(also just check rq and make sure the script isn’t disabled)