You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
Player list that shows all players in a game -
What is the issue? Include screenshots / videos if possible!
When I test out my player list, it only shows the name of the local player.
(Example: Player name is “Player”, it only shows “Player” in the player list even if there is someone else in the game) -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
Putting code in a global script from a local script- didn’t work
Local script:
local players = game:GetService("Players")
local rs = game:GetService("ReplicatedStorage")
local uis = game:GetService("UserInputService")
local ts = game:GetService("TweenService")
local sg = game:GetService("StarterGui")
local plr = players.LocalPlayer
local uid = plr.UserId
local max = players.MaxPlayers
local mainGui = script.Parent
local ui = mainGui.main
local list = ui.list
local presets = ui.presets
local preset = nil
local closeKey = Enum.KeyCode.Tab
local debounce = false
local isOpen = true
local onPos = UDim2.new(0.853, 0 , 0, 0)
local offPos = UDim2.new(1, 0, 0, 0)
local eDir = Enum.EasingDirection.Out
local eSty = Enum.EasingStyle.Quart
local dur = 1
local rep = false
ui.Position = onPos
ui.Visible = true
mainGui.Enabled = true
sg:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
if presets:FindFirstChild("preset1") == nil then
if list:FindFirstChild("preset1") ~= nil then
preset = list.preset1
preset.Parent = presets
preset.Visible = false
end
else
preset = presets.preset1
end
if ui:FindFirstChild("1_"..plr.Name) == nil then
if ui:FindFirstChild(plr.Name) == nil then
local newCell = preset:Clone()
newCell.Name = "1_"..plr.Name
newCell.Parent = list
newCell.username.Text = "[ @"..plr.Name.." ]"
newCell.displayName.Text = plr.DisplayName
newCell.avatar.Image = players:GetUserThumbnailAsync(uid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
newCell.Visible = true
else
local newCell = ui[plr.Name]
newCell.Name = "1_"..plr.Name
end
end
uis.InputBegan:Connect(function(input)
if input.KeyCode == closeKey then
if debounce == false then
debounce = true
if isOpen == true then
ui:TweenPosition(
offPos,
eDir,
eSty,
dur,
rep
)
isOpen = false
elseif isOpen == false then
ui:TweenPosition(
onPos,
eDir,
eSty,
dur,
rep
)
isOpen = true
end
task.wait(dur)
debounce = false
end
end
end)
Global script:
local players = game:GetService("Players")
local mainGui = script.Parent
local ui = mainGui.main
local presets = ui.presets
local preset = nil
local list = ui.list
if presets:FindFirstChild("preset1") == nil then
if list:FindFirstChild("preset1") ~= nil then
preset = list.preset1
preset.Parent = presets
preset.Visible = false
end
else
preset = presets.preset1
end
players.PlayerAdded:Connect(function(new)
local uid = new.UserId
local newCell = preset:Clone()
newCell.Name = new.Name
newCell.Parent = list
newCell.username.Text = "[ @"..new.Name.." ]"
newCell.displayName.Text = new.DisplayName
newCell.avatar.Image = new:GetUserThumbnailAsync(uid, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size420x420)
newCell.Visible = true
end)
Here is a screenshot of the layout:
*I know it doesn’t delete the player when they leave, I plan to do that later.