ChildAdded function not triggering

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!
    When a child gets added to a scrollingframe, it should run the script, but it doesn’t.
  2. What is the issue? Include screenshots / videos if possible!
    No errors, tried debugging and nothing got printed.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    Yes, but they didn’t help with my issue.
    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!
player123.PlayerGui["Main-UI"].MainMenu.TeamsTab.Main.Frame.TeamHolder.ChildAdded:Connect(function(child)
	print("child added")
	if child:IsA("Frame") then
		local teamname2 = child.Name
		local reqs = require(game.ReplicatedStorage.UIServer:FindFirstChild("TeamPermissions"))
		for i,v in pairs(reqs) do
			if v.TeamName == teamname2 then
				if v.AllAllowed == false then
					print("no")
					local lock = player123.PlayerGui["Main-UI"].MainMenu.TeamsTab.Main.LockedTeam:Clone()
					lock.Parent = child
					lock.Visible = true
				elseif player123:GetRankInGroup(11169105) >= v.RankRequirement then
					print("no")
					local lock = player123.PlayerGui["Main-UI"].MainMenu.TeamsTab.Main.LockedTeam:Clone()
					lock.Parent = child
					lock.Visible = true
				else
					print("yes")
				end
			end
		end
	else
		print("not frame")
	end
end)
2 Likes
for i,v in pairs(reqs) do

You did not call :GetChildren().
Also, why are you trying to use a for loop on a required object? require() only works for Modules. Using for i, pairs loops is only necessary for objects with alot of children.

1 Like

Thanks for the reply, I didn’t call getchildren since I’m not tryingto get the children, instead I am getting it from a table.

1 Like

In that case if you are trying to get the table of the module then you should do:

for i, v in pairs(reqs[Table]) do

end

If it doesn’t work tell me

1 Like

The way I did it worked in other scripts, but it doesn’t work here since the “ChildAdded” event doesn’t trigger for some reason.

1 Like

It did trigger, it just broke because you are trying to get the table of a ModuleScript and you didn’t even specify which table.

1 Like

Did it print “child added” when an object has been parented to TeamHolder?

1 Like

But it worked in another script, it’s typed completely the same. The script IS the table, here’s the module script;

local module = {
	{
		TeamName = "Patient",
		GroupId = 0,
		RankRequirement = 0,
		GamepassId = 0,
		AllAllowed = true
	},
	{
		TeamName = "Intensive Care Patient",
		GroupId = 33504510,
		RankRequirement = 255,
		GamepassId = 690258455,
		AllAllowed = false
	},
	{
		TeamName = "Registered Nurse",
		GroupId = 33504510,
		RankRequirement = 25,
		GamepassId = 690297063,
		AllAllowed = false
	},
	{
		TeamName = "Medical Doctor",
		GroupId = 33504510,
		RankRequirement = 30,
		GamepassId = 682853021,
		AllAllowed = false
	},
	{
		TeamName = "Security Officer",
		GroupId = 33504510,
		RankRequirement = 35,
		GamepassId = 682486715,
		AllAllowed = false
	},
	{
		TeamName = "Specialized Response Team",
		GroupId = 33504510,
		RankRequirement = 40,
		GamepassId = 682348986,
		AllAllowed = false
	},
	{
		TeamName = "Biohazards Lab Agent",
		GroupId = 33504510,
		RankRequirement = 45,
		GamepassId = 682830122,
		AllAllowed = false
	},
	{
		TeamName = "Hospital Administration",
		GroupId = 33504510,
		RankRequirement = 50,
		GamepassId = 682730240,
		AllAllowed = false
	},
	{
		TeamName = "Medical Director",
		GroupId = 33504510,
		RankRequirement = 55,
		GamepassId = 690434031,
		AllAllowed = false
	},
	{
		TeamName = "Hospital President",
		GroupId = 33504510,
		RankRequirement = 60,
		GamepassId = 690442131,
		AllAllowed = false
	},
	{
		TeamName = "Co Owners",
		GroupId = 33504510,
		RankRequirement = 65,
		GamepassId = 690237608,
		AllAllowed = false
	},
	{
		TeamName = "Chairperson",
		GroupId = 33504510,
		RankRequirement = 600, --70
		GamepassId = 690238494,
		AllAllowed = false
	},
}

return module

I’m not sure how I can specify which table I’m trying to get when the script looks like this

Do this:

Table1 = {
		TeamName = "Patient",
		GroupId = 0,
		RankRequirement = 0,
		GamepassId = 0,
		AllAllowed = true
	},

instead of:

{
		TeamName = "Patient",
		GroupId = 0,
		RankRequirement = 0,
		GamepassId = 0,
		AllAllowed = true
	},

Notice the difference?

1 Like

Tried it, didn’t work unfortunately. No errors as usual and nothing printed.

1 Like

It should work if done correctly. Here is a link:

By the way, did it print “child added” when an object has been parented to TeamHolder?

1 Like

Thanks for the link.
No, it did not print “child added”.

1 Like

so now we’ve gotten to this point
i have something to ask you
is an object even being parented to teamholder? did you check from the server?

1 Like

I did, since a frame is being parented to teamholder I checked from my clientside, also since the entire script is a LocalScript under “StarterGui”.
Forgot to answer your question - yes, there is a frame being parented to “teamholder”

1 Like

this issue has continued to make me lose and lose more braincells. i won’t provide full scripts, but i will aid you. here are my guesses:

  • your script does not recognize or see any of the children that have been added at all
  • it could also be due to the big chunk of code below print(“child added”) that yielded the script, you could try temporarily removing it and see what happens

by the way, how are you accessing this player “player123”?

player123 is game.Players.LocalPlayer
thanks for all the tips!

First off, what does the output look like? Considering you’ve obviously done some debugging it’d be helpful to let people know so we can pin point the issue

Nothing got printed, and no errors.

where are you doing the cloning and parenting the frame? is it from a serverscript? localscript?

a localscript, sorry for late response