ChildRemoved not Firing but ChildAdded does

.ChildRemoved isn’t firing for some reason, .ChildAdded works just fine, and so does the function it connects to, I even tested manually placing items into the Parties folder, and it fired when I added, but not when I removed them. Its for a lobby system, please help I have no idea why it isn’t working

This is my explorer:
image
and this is the code firing it:

game.ReplicatedStorage.Parties.ChildRemoved:Connect(updatePartyList)
game.ReplicatedStorage.Parties.ChildAdded:Connect(updatePartyList)

The local script is inside of a ScreenGUI in StarterPlayerGui (or PlayerGui depending on how you look at it)

2 Likes

I’m pretty sure it’s ChildRemoving, not ChildRemoved.

First of all, it is ChildRemoved and not ChildRemoving so you used the event correctly.
Add a print statement at the beginning of updatePartList to test if ChildRemoved event was fired. Your event should work so I think the problem is somewhere within updatePartyList function.

2 Likes

I didn’t use ChildRemoving? and I have got a print statement at the very beginning of the function, it fires every single time that a Child is Added, and not once when it is removed, the function works perfectly, It has to be something to do with the calling of it

1 Like

image
this is the output from when I do it, the first “joining party” is when I join the party, the second “joining party” is when I leave the party, “updating party list” only fires on joining (when the folder is added) not on removal

1 Like

we will not be able to help you if you do not provide more information about your code (most importantly the updatePartyList function)

1 Like

@MikeartsRBLX @Arkston , having actually looked into my updatePartyList function, and not assuming its perfect I realised the problem,

function updatePartyList()
	for i, child in pairs(script.Parent.Players.PlayersList:GetChildren()) do
		if child:IsA("Frame") then
			child:Destroy()
		end
	end
	
	for i, party in pairs(game.ReplicatedStorage.Parties:GetChildren()) do
		print("updating party list")
		local partyName = party.Name
		local playerLimit = party:WaitForChild("PlayerLimit").Value
		local playerCount = #party.Players:GetChildren()
		
		local template = script.PartyTemplate:Clone()
		template.PartyName.Text = partyName
		template.PlayerCount.Text = playerCount .. "/" .. playerLimit
		
		party.Players.ChildAdded:Connect(function() 
			template.PlayerCount.Text = #party.Players:GetChildren() .. "/" .. playerLimit 
		end)
		party.Players.ChildRemoved:Connect(function() 
			template.PlayerCount.Text = #party.Players:GetChildren() .. "/" .. playerLimit 
		end)
		
		template.Parent = publicServersList
		publicServersList.CanvasSize = UDim2.new(0, 0, 0, publicServersList.UIListLayout.AbsoluteContentSize.Y)
		template.Join.JoinButton.MouseButton1Click:Connect(function()
			game.ReplicatedStorage.PartySystemRE:FireServer("joinParty", partyName)
		end)
	end
end

I forgot that it was running on a loop depending on how many children there are in the Parties Folder, and that given my party was the only one, when it is deleted the loop doesn’t run

1 Like

I see, good job!

P.S. the stuff I said about ChildRemoving and ChildRemoved was referring to someone who said they think it should be ChildRemoving

1 Like

ah ok, thank you for all your help :smile:

1 Like

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