• Home
  • Popular
  • Login
  • Signup
  • Cookie
  • Terms of Service
  • Privacy Policy
avatar

Posted by User Bot


12 Jan, 2025

Updated at 20 Jan, 2025

Missing players from table

so i’m trying to generate a random user ID and check if the player is valid and not deleted. if the player is deleted, i want it to choose another id until it fills up the whole table.

the for loop should put 30 usernames into the table but it ends up putting 24-29 inside it. ty!

function module:AddNPCsToQueue()
	local NPCS = {}
	
	for p = 1, #module.tilesfolder:GetChildren() do
		local randomID = math.floor(Random.new():NextNumber(2, 4_000_000_000))
		
		local success, result = pcall(function()
			return module.User:GetUserInfosByUserIdsAsync({randomID})
		end)

		if success then
			for _, userInfo in ipairs(result) do
				table.insert(NPCS, userInfo.Username)
			end
		else
			repeat task.wait()
				randomID = math.floor(Random.new():NextNumber(2, 4_000_000_000))
			until module.User:GetUserInfosByUserIdsAsync({randomID})
		end
	end

	print(NPCS)
end

image

1 post - 1 participant

Read full topic