So I have a custom playerlist and I want a hammer icon to show up next to their name on the list
(like this)
The template is for the player’s username which gets cloned when they join and the devicon is also parented to the script and I want it to parent to the player that is the developer’s template
Here’s the script for the player list (I didn’t start the developer icon part in the script yet that’s what I need help with)
local startergui = game:GetService("StarterGui")
local players = game:GetService("Players")
local listframe = script.Parent
local playerlist = listframe.ListPlayers
--default list disable, remove if you're already doing this
repeat
local load = pcall(function()
startergui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
end)
wait(0.2)
until load
local function makebox(name, current)
local listed = script.Template:Clone()
listed.Parent = script.Parent.ListPlayers
listed.Position = UDim2.new(0.032,0,0.013,current*60)
listed.Name = name
listed.Text = name
--you can use your own values here
listed.BackgroundColor3 = script.Parent.ListTitle.BackgroundColor3
listed.TextStrokeColor3 = script.Parent.ListTitle.TextStrokeColor3
listed.TextStrokeTransparency = 0
listed.Size = UDim2.new(0.929, 0, 0.072, 0)
listed.TextScaled = true
listed.TextColor3 = Color3.new(1, 1, 1)
listed.Font = "Cartoon"
local Corner = Instance.new("UICorner", listed)
end
local function reload() --this reloads the player list when called
for _,v in pairs(playerlist:GetChildren()) do
v:Destroy()
end
for _,v in pairs(players:GetChildren()) do
makebox(v.Name, #playerlist:GetChildren())
end
end
local isActive = false
userinput.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.Tab then --will show/hide with tab
if not isActive then
reload() --updates on tab press
isActive = true
listframe.Visible = true
else
isActive = false
listframe.Visible = false
end
end
end)
--updates on player join/leave
players.PlayerAdded:Connect(reload)
players.PlayerRemoving:Connect(reload)
reload()
I can help you.
First, put this in your code (make sure to put it before the local function makebox(name, current) line):
local dev_icon = script:WaitForChild("DevIcon");
local developerIds = {
1822194589,
};
Then, place the player IDs of all the developers of your game inside of the developerIds table (I already put your player ID in there just so you know how it works).
After that, put this in the end of the makebox function:
if table.find(developerIds, players:GetUserIdFromNameAsync(name)) then
dev_icon:Clone().Parent = listed
end
I hope this works for you, tell me if you have any issues.
I decided to shorten the code a lot to make it simpler.