Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Update the :GetChildren() ???

How can i update the :GetChildren() ?? already try with childadded and childremoved like this one but when i try to add like a number value and change the value it wont print

local Checker = ServerStorage:WaitForChild("PlayerItem"):FindFirstChild(plr.Name):GetChildren()

ServerStorage:WaitForChild("PlayerItem"):FindFirstChild(plr.Name).ChildAdded:Connect(function(child)
	Checker = ServerStorage:WaitForChild("PlayerItem"):FindFirstChild(plr.Name):GetChildren()

end)

ServerStorage:WaitForChild("PlayerItem"):FindFirstChild(plr.Name).ChildRemoved:Connect(function(child)
	Checker = ServerStorage:WaitForChild("PlayerItem"):FindFirstChild(plr.Name):GetChildren()
	end)
	
for i,v in pairs (Checker) do
	if v:IsA('NumberValue') then
		v.Changed:Connect(function()
			local Names = v.Name
			local Amount = v.Value
			print(Names, Amount)
		end)
	end
end

1 answer

✓ Accepted answer

You should make a ChildAdded function, and loop through the objects that are already there and establish a ChildAddedEvent in the folder.


local function onChildAdded(child)
      if child:IsA("NumberValue") then
            child.Changed:Connect(function(prop)
                   local Names = child.Name
                   local Amount = child.Value
                   print(Names, Amount)
            end)
      end
end
ServerStorage:WaitForChild("PlayerItem"):FindFirstChild(plr.Name).ChildAdded:Connect(onChildAdded) -- establish a .ChildAdded Event.
for _, child in pairs(ServerStorage.PlayerItem:FindFirstChild(plr.Name):GetChildren()) do -- loop through the children alredy there!
      onChildAdded(child)
end

If this works, please mark this as an answer

This discussion is preserved as it was. New answers, comments, and votes are closed.