So right now i’m trying to make orders for my game so players can complete them for cash.
But I need some help to make it randomized. So the the names will be in the gui and the gui will be there only if there is an order to complete.
So I think that the Gui needs to be created when there is an random order right?
local List = {1, 2, 3, 4, 5, 6}
local TempList = {}
for i = 1, #List do
table.insert(TempList, List(math.random(1, #List))
end
List = TempList
Templist = {}
What this should do is create a new empty list (TempList), put the items from the list (List) in random order in that list (TempList), and then set the list (List) to the newly created list (TempList). And boom, random order.
Because you aren’t making it do anything. companyNAMES[randomtask] will pick a random line of the table.
If you want it to do something, then do:
local randomtask = math.random(#companyNAMES) -- The 1st parameter defaults to 1 if it's not specified, so in this case we can just put #companyNAMES to find the max number in the table.
print(companyNAMES[randomtask])
It will print the random task.
If you want to learn more about tables, go to:
local names = {"Monica", "Joey", "Sarah", "Michel", "Michael", "James", "Adam"}
local companyNAMES = {"Electro Shop", "Cablebar", "Airedable", "Tvus", "Videosify", "Tellyware", "Onaired", "Remixus", "Technomax", "Elevatelly", "Envideos", "Inc.ia", "Cotv", "Coremix", "Edaired", "Unitelly"}
for strings, name in pairs(names) do
for strings, company in pairs(companyNAMES) do
local Len = tonumber(table.getn(names))
local Len2 = tonumber(table.getn(companyNAMES))
wait()
local NewRand = math.random(1, Len)
local companyRand = math.random(1, Len2)
print(names[NewRand])
print(companyNAMES[companyRand])
end
end
@CodedJack I’ve came this far this time but cause the text won’t change to the given names in the metatable. But it says an number anyway to get the random name which is in the meta table?
local names = {"Monica", "Joey", "Sarah", "Phoebe", "Michel", "Michael", "James", "Adam"}
local companyNAMES = {"ElectroShop", "Cablebar" ,"Airedable" ,"Tv.Inc", "Videosify", "Tellyware", "Onaired", "Remixus", "Technomax", "Elevatelly", "Envideos", "Inc.ia", "Cotv", "Coremix", "Edaired", "Unitelly" }
local ReplicatedStorage = game.ReplicatedStorage.TvOrderRMDs
local tvOrdersRMD = {"OldTv", "Salora 58UA330"}
local randomtask = math.random(#companyNAMES) -- The 1st parameter defaults to 1 if it's not specified, so in this case we can just put #companyNAMES to find the max number in the table.
local randomtask2 = math.random(#names)
local guiPlaces = game.StarterGui.ComputerMenu.Orders.Background1.OrderPlaces.Value
if guiPlaces == 0 then
local ORDER = Instance.new("TextButton")
ORDER.Parent = game.StarterGui.ComputerMenu.Orders.Background1
ORDER.Size = UDim2.new(0.25, 0, 0.278, 0)
ORDER.Position = UDim2.new(0.122, 0, 0.146, 0)
ORDER.Name = "Order1"
ORDER.BackgroundColor3 = Color3.fromHSV(0.54425, 0.886275, 1)
ORDER.Text = #names
local Name = Instance.new("TextLabel")
Name.Name = "Name"
local CircleGui = Instance.new("UICorner")
CircleGui.Parent = ORDER
guiPlaces = guiPlaces + 1
end
local names = {"Monica", "Joey", "Sarah", "Phoebe", "Michel", "Michael", "James", "Adam"}
local companyNAMES = {"ElectroShop", "Cablebar" ,"Airedable" ,"Tv.Inc", "Videosify", "Tellyware", "Onaired", "Remixus", "Technomax", "Elevatelly", "Envideos", "Inc.ia", "Cotv", "Coremix", "Edaired", "Unitelly" }
local ReplicatedStorage = game.ReplicatedStorage.TvOrderRMDs
local tvOrdersRMD = {"OldTv", "Salora 58UA330"}
local randomtask = names[math.random(#names)] -- The 1st parameter defaults to 1 if it's not specified, so in this case we can just put #companyNAMES to find the max number in the table.
local randomtask2 = math.random(#companyNAMES)
local guiPlaces = game.StarterGui.ComputerMenu.Orders.Background1.OrderPlaces.Value
if guiPlaces == 0 then
local ORDER = Instance.new("TextButton")
ORDER.Parent = game.StarterGui.ComputerMenu.Orders.Background1
ORDER.Size = UDim2.new(0.25, 0, 0.278, 0)
ORDER.Position = UDim2.new(0.122, 0, 0.146, 0)
ORDER.Name = "Order1"
ORDER.BackgroundColor3 = Color3.fromHSV(0.54425, 0.886275, 1)
ORDER.Text = randomtask
local Name = Instance.new("TextLabel")
Name.Name = "Name"
local CircleGui = Instance.new("UICorner")
CircleGui.Parent = ORDER
guiPlaces = guiPlaces + 1
end
First:
This variable was only getting a number.
Changed to:
local randomtask = names[math.random(#names)]
The new variable is picking a random name by referencing table[number].
Second:
Referencing a table is not going to work. So, we can change this to the variable I just edited (randomtask).
Changed to:
ORDER.Text = randomtask
This is putting the Text as the random name picked in the randomtask variable.
If you want to get the text of the random company name, you can do the same thing. Change the randomtask2 variable to work, and put the text as the randomtask2 variable.