好吧,所以即時通訊製作一個關注的朋友GUI的東西,即時通訊嘗試從名稱中使用GetUserIdFromNameAsync的字符串。即時嘗試電腦,所以我沒有得到錯誤,但它返回零,即使它的名字,我知道的作品,因爲我經常在上面打電話。並且它返回打印中的id,但是當我嘗試pcall時,然後使用它,如果它每次返回nil並轉到我的else語句。pcall a GetUserIdFromNameAsync()
local TeleportService = game:GetService("TeleportService")
script.Parent.OnServerEvent:connect(function(player, id)
place = player.GuiFolder
print(game.Players:GetUserIdFromNameAsync(id))
--ISSUE IN LINE BELOW-- ISSUE IS IN THE LINE BELOW
friend, msg = pcall(game.Players:GetUserIdFromNameAsync(id))
if friend then
print(player.Name, player, player.PlayerGui.MainMenu.Name)
if player:IsFriendsWith(friend) then
place.IsFriend.Value = true
local success, errorMsg, placeId, instanceId = TeleportService:GetPlayerPlaceInstanceAsync(friend)
if success then
place.foundplayerbar.Value = "Found player. Would you like to join?"
place.Activated.Value = true
else enter code here
place.errorbar.Value = "ERROR: Player not online!"
end
else place.errorbar.Value = "ERROR: Not Friends with person!"
end
else place.errorbar.Value = "ERROR: Player doesn't exist!"
end
end)