got myself a Working Playerlist, however it doesn’t reflect to everyone and therefore only get’s copied to a local player, can anyone help me out on this one? This only gets reflected on 1 player.
I used FireAllClients on ServerScripts. Can anyone help me out?
--// Client Side
function module.setUpPlayerList(plr: Player)
local Template = script:WaitForChild("TemplatePlayerList"):Clone()
local success1, AvatarIMG_Headshot = pcall(PLYR_SRVC.GetUserThumbnailAsync, PLYR_SRVC, plr.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
local success2, AvatarIMG_Bust = pcall(PLYR_SRVC.GetUserThumbnailAsync, PLYR_SRVC, plr.UserId, Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
local ScrollingFrame = plr:WaitForChild("PlayerGui").CoreGui.PlayerFrame.PlayerFrame.PlayerList
local ForCopy = STARTERGUI_SRVC.CoreGui.PlayerFrame.PlayerFrame.PlayerList
Template.Parent = ForCopy
Template.Parent = ScrollingFrame
Template.Name = plr.Name
local main_Contents = Template
main_Contents.PlayerPicture.Image = AvatarIMG_Headshot
main_Contents.DisplayName.Text = plr.DisplayName
main_Contents.Username.Text = plr.Name
local secondary_Contents = main_Contents:WaitForChild("MoreInfo_FRAME"):WaitForChild("FRAME")
secondary_Contents.PlayerPicture.Image = AvatarIMG_Bust
secondary_Contents.DisplayName.Text = plr.DisplayName
secondary_Contents.AccountAge.Text = "Account Age: "..plr.AccountAge
secondary_Contents.PlayerName.Text = plr.Name
warn(SYS_String, "PlayerList for player", plr.Name, "is created.")
end
--// this is the Server Side
local function onPlayerAdded(plr: Player)
PlayerUpdateListEvent:FireAllClients(plr, "PlayerEntered")
PLYR_HANDLER.SetUp(plr)
LEADERBOARD_DATA.LoadData(plr)
CASH_DATA.LoadData(plr)
end
and then Client Listens:
--// Client Side
local function updatePlayerList(plr: Player, val: string)
if val == "PlayerEntered" then
moduleClient.setUpPlayerList(plr)
elseif val == "PlayerLeft" then
moduleClient.removePlayerList(plr)
end
end
I’m super sorry for my hour late response, was doing something. I can prolly assume that the “updatePlayerList” function is connected to your remote event’s OnServerEvent listener
But could you show that line (OnServerEvent line). The code you just sent seems fine
isnt it suppose to be onClientEvent? or onServerEvent? since the remote fires from Server. And also no worries, been trying here to fix it myself too xd
I actually have updated the code and currently testing it rn:
--// the current Module Code rn
function module.setUpPlayerList()
local plrList = STARTERGUI_SRVC.PlayerListGui.PlayerFrame.PlayerFrame.PlayerList
local Template = script:WaitForChild("TemplatePlayerList"):Clone()
local allPlayers = PLYR_SRVC:GetPlayers()
for _, plrList in ipairs(plrList:GetChildren()) do
if plrList:IsA("Frame") then
plrList:Destroy()
print("Deleted Current Playlist for a Refresh...")
end
end
for _, plrs in allPlayers do
print("Creating new PlayerList...")
print("Current Players: ", allPlayers)
local success1, AvatarIMG_Headshot = pcall(PLYR_SRVC.GetUserThumbnailAsync, PLYR_SRVC, plrs.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
local success2, AvatarIMG_Bust = pcall(PLYR_SRVC.GetUserThumbnailAsync, PLYR_SRVC, plrs.UserId, Enum.ThumbnailType.AvatarThumbnail, Enum.ThumbnailSize.Size420x420)
local plrGui_plrList = plrs.PlayerGui.PlayerListGui.PlayerFrame.PlayerFrame.PlayerList
local ForCopy = STARTERGUI_SRVC.PlayerListGui.PlayerFrame.PlayerFrame.PlayerList
Template.Parent = ForCopy
Template.Name = plrs.Name
local main_Contents = Template
main_Contents.PlayerPicture.Image = AvatarIMG_Headshot
main_Contents.DisplayName.Text = plrs.DisplayName
main_Contents.Username.Text = plrs.Name
local secondary_Contents = main_Contents:WaitForChild("MoreInfo_FRAME"):WaitForChild("FRAME")
secondary_Contents.PlayerPicture.Image = AvatarIMG_Bust
secondary_Contents.DisplayName.Text = plrs.DisplayName
secondary_Contents.AccountAge.Text = "Account Age: "..plrs.AccountAge
secondary_Contents.PlayerName.Text = plrs.Name
Template:Clone().Parent = plrGui_plrList
warn(SYS_String, "PlayerList for player", plrs.Name, "is created.")
end
end
I just realized that right now xD so wait… I should just let the creation of new playerlist directly on the Server than the client? bruh moment-
btw, I updated the code in module (the client uses this module) and this works and it gets replicated to everyone.
function module.setUpPlayerList()
local plrList = STARTERGUI_SRVC.PlayerListGui.PlayerFrame.PlayerFrame.PlayerList
local Template = script:WaitForChild("TemplatePlayerList"):Clone()
local allPlayers = PLYR_SRVC:GetPlayers()
for _, plrList in ipairs(plrList:GetChildren()) do
if plrList:IsA("Frame") then
plrList:Destroy()
print("Deleted Current Playlist for a Refresh...")
end
end
local plrGui_plrList = PLYR_SRVC.LocalPlayer.PlayerGui.PlayerListGui.PlayerFrame.PlayerFrame.PlayerList
for _, plrs in allPlayers do
print("Creating new PlayerList...")
print("Current Players: ", allPlayers)
local success1, AvatarIMG_Headshot = pcall(PLYR_SRVC.GetUserThumbnailAsync, PLYR_SRVC, plrs.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
local success2, AvatarIMG_Bust = pcall(PLYR_SRVC.GetUserThumbnailAsync, PLYR_SRVC, plrs.UserId, Enum.ThumbnailType.AvatarThumbnail, Enum.ThumbnailSize.Size420x420)
local ForCopy = STARTERGUI_SRVC.PlayerListGui.PlayerFrame.PlayerFrame.PlayerList
Template.Parent = ForCopy
Template.Name = plrs.Name
local main_Contents = Template
main_Contents.PlayerPicture.Image = AvatarIMG_Headshot
main_Contents.DisplayName.Text = plrs.DisplayName
main_Contents.Username.Text = plrs.Name
local secondary_Contents = main_Contents:WaitForChild("MoreInfo_FRAME"):WaitForChild("FRAME")
secondary_Contents.PlayerPicture.Image = AvatarIMG_Bust
secondary_Contents.DisplayName.Text = plrs.DisplayName
secondary_Contents.AccountAge.Text = "Account Age: "..plrs.AccountAge
secondary_Contents.PlayerName.Text = plrs.Name
Template:Clone().Parent = plrGui_plrList
warn(SYS_String, "PlayerList for player", plrs.Name, "is created.")
end
end
tell me alternative ways I can make this better and efficient than the current ones I am doing xD
Let each client manage their own gui. I had a similar issue recently and I just added PlayerAdded and PlayerRemoving connections on the client, it worked after that.