-
What do you want to achieve? Keep it simple and clear!
I want to make it so my function can recieve string and nil, but not in a table. -
What is the issue? Include screenshots / videos if possible!
Not all codepaths return ‘string’ in the editor. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried(string,nil)
and(string ? nil)
.
Here’s my full code:
local Players = game:GetService("Players")
local rs = game:GetService("RunService")
local module = {}
function module:GetAvatar(userId:number,thumbType:Enum.ThumbnailType,thumbSize:Enum.ThumbnailSize): (string)
if userId then
local content, isReady = Players:GetUserThumbnailAsync(userId, thumbType, thumbSize)
if isReady then
return tostring(content)
end
else
if rs:IsClient() then
local content, isReady = Players:GetUserThumbnailAsync(game.Players.LocalPlayer.UserId, thumbType, thumbSize)
if isReady then
return tostring(content)
end
end
end
end
return module