Hello, I am trying to randomly generate users, and put them on the map, but the problem is that sometimes I recieve the error:
Players:CreateHumanoidModelFromUserId() failed because HTTP 400 (Bad Request) - Server - BotGeneration:17
local botName
local newId = math.random(100000000,7000000001)
local success, err = pcall(function()
botName = game.Players:GetNameFromUserIdAsync(newId)
end)
if not success then
newBot()
end
local bot = Players:CreateHumanoidModelFromUserId(newId)
How would I fix this, this only happens around 25% of the time, and it’s on this line:
local bot = Players:CreateHumanoidModelFromUserId(newId)
You can certainly use pcall to detect when a function errors, and then subsequently retry the random user ID. For more information, check out this post: