Randomly pick something in a table without reusing it until everything has been used

Here is the full script, i tested it and it works now

local Table = {
	"Notification: We hope you're enjoying the first version of ---! ☕",
	"Notification: Make sure to like & favorite the game! 👍⭐",
	"Notification: Many more foods & items are on their way!",
	"We thank you for your dedication to ---. 💕"
}

local UsedTable = {}
local NotificationCooldown = 10

local function SendNotification()
	if #Table ~= #UsedTable then
		local RandomNumber = math.random(1, #Table)
		local RandomThing = Table[RandomNumber]

		if not table.find(UsedTable, RandomThing) then
			print(RandomThing)
			
			table.insert(UsedTable, RandomThing)
		else
			SendNotification()
		end
	else
		table.clear(UsedTable)
		
		SendNotification()
	end
end

while task.wait(NotificationCooldown) do
	SendNotification()
end

i changed the script again because when it chooses the same random table, it wont print, so then i fixed it

5 Likes