local randomscene = game.Scenes:GetChildren()[math.random(1, 2).ReplicatedStorage.Scenes:GetChildren()]
wait(30)
while true do
--code here to display scenes/call table
end ```
Brand new to creating tables.
You haven’t created any tables with this code, what is your goal?
Also,
math.random(1, 2).ReplicatedStorage.Scenes:GetChildren()
will error, you’re trying to index a number
Yeah, as @yes35go said, you aren’t creating a table. Try this instead:
local scenes = {game.Workspace.Scenes:GetChildren()}
local randomscene = math.random(1, #scenes)
while task.wait(30) do
--code goes here
end
No need to wrap in curly braces, should be:
local scenes = [container]:GetChildren()
there is no such a service called “Scenes” i think you misspelled the path and meant ReplicatedStorage.
also your variable must be like so :
local randomscene = game.ReplicatedStorage.Scenes:GetChildren()[math.random(1, #game.ReplicatedStorage.Scenes:GetChildren()]
if you want to have a “randomscene” every 30 secs you must put the variable inside the loop like so
while true do
local randomscene = game.ReplicatedStorage.Scenes:GetChildren()[math.random(1, #game.ReplicatedStorage.Scenes:GetChildren()]
task.wait(30)
end
It would need curly braces because he’s working with a table and in order for the math.random function to work you would need to keep it a table
:GetChildren() returns a table
Either way they should both work though
It won’t necessarily “not work” but it will produce an unwanted result. This line will return “game.Workspace.Scenes:GetChildren()” table every time it is ran rather than a random object within the container:
local scenes = {game.Workspace.Scenes:GetChildren()} -- returns another table
local randomscene = math.random(1, #scenes)