I've been trying to make it so that the script chooses a random skybox and inserts it into "game.lighting". But I can't seem to get it to work. Here's my code. Thanks!
if value.Value == 9 then local sky1 = workspace.Skies.Darkness local sky2 = workspace.Skies.DeepSpace local sky3 = workspace.Skies["Night Sky"] local sky4 = workspace.Skies.RedNight local sky5 = workspace.Skies.Sky local skies = {sky1,sky2,sky3,sky4,sky5} local skyduplicat = math.random(1, #skies) skyduplicat.Parent = game.Lighting end
You're attempting to parent the number that was returned by the math.random
function.
As the math.random
method will return a random number from the provided min and max parameters, you can use the returned number to index the object in the table.
local number = math.random(1, #skies) skies[number].Parent = game.Lighting