I'm making a custom Leaderboard GUI. ChildAdded event is not firing. Output reads 1. Neither 2 or 3 appear.
local Player = game:GetService('Players').LocalPlayer
local PlayerGui = Player:WaitForChild('PlayerGui')
local Frame = PlayerGui.Leaderboard.Frame
print(1)
local function IncreaseFrame()
print(2)
if Frame.Size.Y.Offset < 245 then
print(3)
Frame.Size.Y.Offset = Frame.Size.Y.Offset + 20
end
end
Frame.ChildAdded:Connect(IncreaseFrame)
Here is the code which adds a TextLabel to Frame on player join (same script):
local TL = Instance.new('TextLabel')
TL.Name = Player.Name
TL.Text = Player.Name
TL.AnchorPoint = Vector2.new(0.5,0)
TL.Position = Frame.User.Position
TL.Size = Frame.User.Size
TL.TextSize = 16
TL.TextStrokeTransparency = 0.5
TL.Font = Enum.Font.GothamSemibold
TL.BackgroundTransparency = 1
TL.TextColor3 = Color3.fromRGB(255,255,255)
TL.TextXAlignment = Enum.TextXAlignment.Left
TL.Parent = Frame -- THIS SHOULD FIRE CHILDADDED

5 comments
Are these in the same script? Im Just wondering because In the second Block of code I what is the definition of frame variable?
Yes, same LocalScript. TL.Parent = Frame is referring to the same Frame variable in the first code block.
Do you ever change the Frame variable anywhere else in the script, like referencing another frame with same variable? Because it should work. :/
you can check by changing last line to TL.Parent = PlayerGui.Leaderboard.Frame, and if it works then you are changing the Frame variable somewhere else
Maybe the text label is being added before child added event listener could be established?