Skip to content

Commit

Permalink
Add player display names and merge Util.GetNames into transformInstan…
Browse files Browse the repository at this point in the history
…ceSet
  • Loading branch information
itsrenderman committed Dec 27, 2024
1 parent 442f98f commit e06d115
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions Cmdr/Shared/Util.lua
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,12 @@ local function transformInstanceSet(instances)
local names = {}

for i = 1, #instances do
names[i] = instances[i].Name
local object = instances[i]
if typeof(object) == "Instance" and object:IsA("Player") then
names[i] = if object.DisplayName == object.Name then object.Name else `{object.DisplayName} ({object.Name})`
continue
end
names[i] = object.Name or tostring(object)
end

return names, instances
Expand Down Expand Up @@ -122,12 +127,7 @@ end
If no Name property is present, then tostring will be called instead.
]=]
function Util.GetNames(instances: any): { string }
local names = {}

for i = 1, #instances do
names[i] = instances[i].Name or tostring(instances[i])
end

local names, _ = transformInstanceSet(instances)
return names
end

Expand Down

0 comments on commit e06d115

Please sign in to comment.