Assume that those names are players. There are 3 countryballs (Characters)
German Ball
US Ball
UK Ball
In the picture, it shows that Michael Jackson will be UK Ball for the first 5 seconds. And the next is… Khorol. And next again is… Rizal and continues every 5 seconds. For everyone that are not selected to be UK Ball are going to be German Ball either US Ball.
All you have to do is how to make a code example like I sent the picture? Just some simple code like printing the output. I’ll adjust any further in my game later.
Are you trying to have a system where it randomly selects a player every 5 seconds who hasn’t had the UK ball, then makes them that ball, and gives everyone else either the US ball or the german ball?
Then, if all players have been chosen before, the list resets and it begins randomly choosing them again?
Are you assuming that the player who hasn’t been UK Ball will be selected randomly while others who had been it can’t be UK Ball? I mean… Yeah. I don’t want the same person (Who was a UK Ball currently) will be the next UK Ball.
Yeah but I need an example code of that kind probability. The system randomly pick players who has not been UK Ball before relist those players who has been UK Ball. Cannot be twice in a row. Resets after everyone has been UK Ball. Not selected players will be German either US. (According to RNG be oz it’s his job)
local contenders = {"Rizal", "Razak", "Khorol", "Zaini Hamzari", "Asri", "Johnny Sins", "Michael Jackson"} -- The people included in your probability test.
local assign = {"German Ball", "US Ball", "UK Ball"} -- The possible elements that can be assigned to each person.
local function outputAssignedContenders(specialContenderIndex, assignContenderItemIndex, seed)
-- Let's clone both arrays, and delete the items we selected in the first two parameters.
local assignClone = table.clone(assign)
local assignedItem = assignClone[assignContenderItemIndex]
table.remove(assignClone, assignContenderItemIndex)
local contendersClone = table.clone(contenders)
local specialContender = contendersClone[specialContenderIndex]
table.remove(contendersClone, specialContenderIndex)
local selections = {}
-- Let's go assign the special contender with the element that we selected.
selections[specialContender] = assignedItem
-- Loop through every other person. Let's have a `Random` class and assign it to the variable `rand`.
local rand = Random.new(seed) -- The seed for randomization. Must be a number.
for _, contender in contendersClone do
local nextInteger = rand:NextInteger(1, #assignClone) -- Change the random value.
selections[contender] = assignClone[nextInteger]
end
-- Print the `selections` table
print(selections)
end
local selectedContender = 1 -- The starting index.
while true do
selectedContender += 1 -- Increment `selectedContender` by 1.
if selectedContender > #contenders then
selectedContender = 1 -- Loop back to the starting index.
end
outputAssignedContenders(selectedContender, 3, 100)
-- Input the selected contender, the item that the selected contender will be assigned to, and the seed value.
task.wait(5)
end