Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local ReplicatedStorage = game:GetService("ReplicatedStorage")
- local Lighting = game:GetService("Lighting")
- -- Sky options and spawn weights
- local skies = {
- {skyModel = ReplicatedStorage.Skies.Sky, weight = 11},
- {skyModel = ReplicatedStorage.Skies.GrayCloudSky, weight = 8},
- {skyModel = ReplicatedStorage.Skies.RealisticSky, weight = 1}
- }
- -- Total weight
- local totalWeight = 0
- for _, option in pairs(skies) do
- totalWeight += option.weight
- end
- -- Random sky selection
- local pick = math.random(1, totalWeight)
- local current = 0
- local chosenSkyModel
- for _, option in pairs(skies) do
- current += option.weight
- if pick <= current then
- chosenSkyModel = option.skyModel
- break
- end
- end
- -- Clear current Lighting and apply new sky and effects
- if chosenSkyModel then
- Lighting:ClearAllChildren()
- for _, item in pairs(chosenSkyModel:GetChildren()) do
- local clone = item:Clone()
- clone.Parent = Lighting
- end
- print("Chosen sky:", chosenSkyModel.Name)
- end
Advertisement
Add Comment
Please, Sign In to add comment