Help with updating a frame when a player joins

Hello!
I’m working on a project right now which when a player joins they are added to a frame. Basically think of it as a custom playlist. But, I have run into a problem that I am unsure how to fix. Basically, when a new player joins, they are the only one on that frame. But for people who are already in the game, their username is added with no problems. How can I fix make it update for all players? Thank you if you are able to help, if not have a great rest of your day :smiley:

-- Client
for i,v in pairs(CAD.Buttons:GetChildren()) do
	if v.ClassName == "TextButton" then
		v.MouseButton1Click:Connect(function()
			for _,x in pairs(CAD:GetChildren()) do
				if x.Name ~= "Buttons" and x.ClassName == "Frame" then
					x.Visible = false
					CAD:FindFirstChild(v.Name).Visible = true
				end
			end
		end)
	end
end

local function UpdatePlayer(parent, name)
	local ParentHere = CAD:FindFirstChild(parent):FindFirstChild("Players")
	local newPlr = ParentHere.Example:Clone()
	newPlr.Parent = ParentHere
	newPlr.Name = tostring(name)
	newPlr.PlayerName.Text = tostring(name)
	newPlr.Visible = true
end

local function RemovePlayer(parent, name)
	CAD:FindFirstChild(parent):FindFirstChild("Players"):FindFirstChild(name):Destroy()
end

Remotes.UpdateRecords.OnClientEvent:Connect(function(msg, newPlayer)
	if msg == "New" then
		UpdatePlayer("Records", newPlayer)
	elseif msg == "Remove" then
		RemovePlayer("Records", newPlayer)
	end
end)

-- Server
game.Players.PlayerAdded:Connect(function(player)
	UpdateRecords:FireAllClients("New", player)
	
	local folder = Instance.new('Folder', player)
	folder.Name = 'PlayerStats'
	
	local warrant = Instance.new('IntValue', folder)
	warrant.Name = 'Warrant'
	warrant.Value = math.random(1,5)
end)

game.Players.PlayerRemoving:Connect(function(player)
	UpdateRecords:FireAllClients("Remove", player)
end)

(I can provide code if that helps)

Yes, can you please provide the code, and also more information on what you are trying to achieve

Updated

(30 charsssssssssssssss)

Sorry, I didn’t see the last part of what you asked. Basically, when a new player joins, my goal is to get it to update for all players in-game. Like, the current frame with all the players refreshes I guess? I’m not the best at explaining so, I’m sorry about that.

1 Like