Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support player display names and merge Util.GetNames with transformInstanceSet #342

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading