RobloxScripterAI
Discord ↗
Link Copied to Clipboard
×
"there is now duplicates of players"
-- To fix this issue, we need to ensure that when a player is removed, the corresponding frame is also removed. Here is how to do it: -- roblox script game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false) local template = script:WaitForChild("PlayerFrame") local scroller = script.Parent:WaitForChild("Scroller") scroller.Visible = true local playerFrames = {} -- Keep track of player frames function updatePlayers() for i, child in pairs(scroller:GetChildren()) do if child:IsA("Frame") then child:Destroy() end end for i, plr in pairs(game.Players:GetPlayers()) do local img = game.Players:GetUserThumbnailAsync(plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420) local templateClone = template:Clone() templateClone.DisplayName.Text = plr.DisplayName templateClone.RealName.Text = "@" .. plr.Name local part = Instance.new("Part") part.Shape = Enum.PartType.Cylinder part.Orientation = Vector3.new(0, -90, 0) part.Size = Vector3.new(1, 1, 1) part.Transparency = 1 local decal = Instance.new("Decal", part) decal.Face = Enum.NormalId.Right decal.Texture = img local camera = Instance.new("Camera") camera.CFrame = part.CFrame * CFrame.Angles(0, math.rad(90), 0) Vector3.new(0, 0, 1.25) templateClone.CharacterImage.CurrentCamera = camera camera.Parent = templateClone.CharacterImage part.Parent = templateClone.CharacterImage templateClone.Parent = scroller playerFrames[plr] = templateClone -- Store reference to frame end end game.Players.PlayerAdded:Connect(function() task.wait(0.5) -- wait for the player to fully join updatePlayers() end) game.Players.PlayerRemoving:Connect(function(plr) if playerFrames[plr] then playerFrames[plr]:Destroy() -- Remove frame when player leaves playerFrames[plr] = nil end end) updatePlayers() -- initial update