I have the following script:
local CreatorID = game.CreatorId
local success, CreatorInfo = pcall(function()
return Players:GetUserInfosByUserIdsAsync({CreatorID})
end)
local CreatorDisplayName = CreatorInfo.DisplayName
local UseDisplayName = true
if not UseDisplayName then
CreatorLabel.Text = "By "..CreatorName
else
CreatorLabel.Text = "By "..CreatorDisplayName --erroring line
end
However, I get the following error:
Players.octav20071.PlayerGui.LoadingScreen.BlackFrame.Script:39: attempt to concatenate string with nil
What’s the issue?
Edit: I have also tried this:
local success, CreatorInfo = pcall(function()
if not success then warn("warning") return end
return Players:GetUserInfosByUserIdsAsync({CreatorID})
end)
…and it printed “warning”.
1 Like
Hmm should work but… try this I guess?
local CreatorID = game.CreatorId
local success, CreatorInfo = pcall(function()
return Players:GetUserInfosByUserIdsAsync({CreatorID})
end)
local UseDisplayName = true
if not UseDisplayName then
CreatorLabel.Text = "By "..CreatorName
else
CreatorLabel.Text = "By ".. CreatorInfo.DisplayName --erroring line
end
I get the following error now:
Players.octav20071.PlayerGui.LoadingScreen.BlackFrame.Script:40: attempt to index nil with 'DisplayName'
…?
Where line 40 is the line you edited
By the way where’s the CreatorName variable at?
Full local
s:
-- Services
local GroupService = game:GetService("GroupService")
local MarketPlaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local UserService = game:GetService("UserService")
-- Setting up the Game information, such as Creator Name, Game Name
local GameId = game.PlaceId
local GameInfo = MarketPlaceService:GetProductInfo(GameId)
local CreatorID = game.CreatorId
local success, CreatorInfo = pcall(function()
if not success then warn("warning") return end
return UserService:GetUserInfosByUserIdsAsync({CreatorID})
end)
local CreatorType = game.CreatorType
local CreatorName = Players:GetNameFromUserIdAsync(CreatorID)
--local CreatorDisplayName = CreatorInfo.DisplayName
local GameName = GameInfo.Name
local GameIcon = GameInfo.IconImageAssetId
-- Setting up the UI variables
local Frame = script.Parent
local GraphicsFrame = Frame.GraphicsFrame
local InfoFrame = Frame.InfoFrame
-- UI pieces we're gonna use
local CreatorLabel = InfoFrame.CreatorLabel
local PlaceLabel = InfoFrame.PlaceLabel
local PlaceIcon = InfoFrame.PlaceIcon
local RobloxSpinner = GraphicsFrame.LoadingImage
local AdditionalText = InfoFrame.UiMessageFrame.UiMessage
-- SETTINGS
-- The variable below is the text you will see at AdditionalText (optional)
local AdditionalText_Text = ""
-- Set to true if you want to use the Creator's display name instead of username
local UseDisplayName = true
I don’t really know what’s the issue
I do recommend taking a look here
I did. I did 10 times. I used the code sample with the pcall too…?
1 Like
I’m currently not on studio. I’ll go in a bit. I’ll inform you if I find anything new
You’re using the function incorrectly, it returns a table of dictionaries with the info that you wanted
If you want to get the display name in this case, you’d do CreatorInfo[1].DisplayName
, or CreatorInfo[1]["DisplayName"]
since you’re only inputting 1 userid, there’s a chance it can error is roblox services to get the info is down or for other reasons, so make sure to put some checks as well
I really doubt the services going down anytime soon, since I am checking the Status Page everyday.
And, it works. Thanks!
1 Like