im changing the text of the textlabel and the image of a imagelabel, but they are not changing with no errors, and they are printing “image” and “yooo” which means the code has been run this is my ONLY script that does stuff with GUI:
workspace.Lobbies.ChildAdded:Connect(function(child)
if child:IsA("Folder") then
print("yooo")
local Clone = GroupFrame:Clone()
Clone.Parent = JoinableLobbies
GroupFrame.nameLabel.Text = child.Name
for i,v in game.Players:GetPlayers() do
print(v.Name, child.Name)
if v.Name == child.Name then
local image = game.Players:GetUserThumbnailAsync(v.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
GroupFrame.Leader.Image = image
print("image")
end
end
end
end)
The script may be loading after the item already loaded. You have to do it for that case:
function initiate(child)
if child:IsA("Folder") then
print("yooo")
local Clone = GroupFrame:Clone()
Clone.Parent = JoinableLobbies
GroupFrame.nameLabel.Text = child.Name
for i,v in game.Players:GetPlayers() do
print(v.Name, child.Name)
if v.Name == child.Name then
local image = game.Players:GetUserThumbnailAsync(v.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
GroupFrame.Leader.Image = image
print("image")
end
end
end
end
for _, child in workspace.Lobbies:GetChildren() do
initiate(child)
end
workspace.Lobbies.ChildAdded:Connect(initiate)
the issue appears to be that the TextLabel and ImageLabel properties are not updating as expected, despite the code executing without errors, so, i recode the script, also, i improved some stuff, making it more long, here:
-- references
local Players = game:GetService("Players")
local LocalPlayer = Players.LocalPlayer
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- gui
local PlayerGui = LocalPlayer:WaitForChild("PlayerGui")
local JoinableLobbies = PlayerGui:WaitForChild("JoinableLobbies") -- Adjust this path as necessary
local GroupFrame = JoinableLobbies:WaitForChild("GroupFrame") -- Template frame to clone
-- lobby creation mechanic
local function onLobbyAdded(child)
if child:IsA("Folder") then
print("New lobby detected:", child.Name)
-- temp frame clone
local clone = GroupFrame:Clone()
clone.Parent = JoinableLobbies
clone.Name = child.Name
-- namelabel updater
local nameLabel = clone:FindFirstChild("nameLabel")
if nameLabel and nameLabel:IsA("TextLabel") then
nameLabel.Text = child.Name
else
warn("nameLabel not found or is not a TextLabel in clone:", clone.Name)
end
-- update the Leader image
local leaderImage = clone:FindFirstChild("Leader")
if leaderImage and leaderImage:IsA("ImageLabel") then
for _, player in pairs(Players:GetPlayers()) do
if player.Name == child.Name then
local userId = player.UserId
local thumbType = Enum.ThumbnailType.HeadShot
local thumbSize = Enum.ThumbnailSize.Size420x420
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
if isReady then
leaderImage.Image = content
print("Updated leader image for:", player.Name)
else
warn("Thumbnail not ready for player:", player.Name)
end
break
end
end
else
warn("Leader ImageLabel not found or is not an ImageLabel in clone:", clone.Name)
end
end
end
-- connect the function to the ChildAdded event
workspace.Lobbies.ChildAdded:Connect(onLobbyAdded)