Hello Developers,
I’m working on a custom playlist, similar to Murder Mystery 2. Although, I’ve run into a problem with displaying the playlist for multiple people, along with setting NameTag colors. Here’s my script, please let me know what I did incorrectly.
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Health, false)
local LocalPlayer = game.Players.LocalPlayer;
local leaderboard = script.Parent.Parent.playerlist;
local NameTags = game.ReplicatedStorage.GetModuleServer:InvokeServer("NameTags");
local LevelData = {};
function Updateleaderboard()
local PlayerTable = {};
for _,Player in pairs(game.Players:GetChildren()) do
if not LevelData[Player.Name] then
local coinAmnt = game.Players:FindFirstChild(LocalPlayer.Name).Coins.Value
if coinAmnt ~= nil then
LevelData[Player.Name] = {};
end
end;
if LevelData[Player.Name] ~= nil then
table.insert(PlayerTable, {
Player = Player;
LD = LevelData[Player.Name]
});
end;
end
for i,Table in pairs(PlayerTable) do
local Player = Table.Player;
if Player ~= nil then
local NewLabel = script.PlayerLabel:Clone();
NewLabel.Name = "Player" .. i;
local LD = LevelData[Player.Name];
local LeaderboardPlayer = leaderboard:FindFirstChild("Player"..i)
if LeaderboardPlayer ~= nil then
ldrbrdplr:Destroy()
end
local Prefix = ""
local PlayerObj = Instance.new("ObjectValue", NewLabel);
PlayerObj.Name = "PlayerObj"
PlayerObj.Value = Player;
NewLabel.Text = " " .. Prefix .. Player.Name
local Color = NameTags[ tostring(Player.userId) ];
if Color then
NewLabel.TextColor3 = Color; -- troubles with colors here
end
NewLabel.Parent = leaderboard;
if Player == LocalPlayer then
NewLabel.TextStrokeColor3 = Color3.new(15/255,15/255,15/255);
end
wait(1)
Updateleaderboard()
end
end
end
Updateleaderboard()