Need help with my script

So I made a gui that shows every players name in the server. Everything works except for the part when someone leaves. I’m trying to get the frame of the player who left removed, but it does not work. Did some research and found nothing related to my topic. Here’s the script. Thanks in advance!

Server script
local playerLeftEvent = game.ReplicatedStorage.RemoteEvents:WaitForChild("PlayerLeft")

game.Players.PlayerRemoving:Connect(function(plr)
	playerLeftEvent:FireAllClients(plr)
end)

Local script
local mainFrame = script.Parent:WaitForChild("MainFrame")
local sample = mainFrame:WaitForChild("Sample")
local playerLeftEvent = game.ReplicatedStorage.RemoteEvents:WaitForChild("PlayerLeft")

playerLeftEvent.OnClientEvent:Connect(function(plr)
	for _,v in pairs(mainFrame:GetChildren()) do
		if plr.Name == v.Name then
			v.Name:Destroy()
			print("Succes")
		end
	end
	
end)
1 Like

Nvm fixed it.fasdfasfasdfasfasfasdf