Log in to vote
0

[SOLVED] Check for a Sky?

Asked by
sgsharp 265 Moderation Voter
7 years ago

I am currently in the process of creating a plugin. The purpose of that plugin is to allow the user to choose sky boxes freely.

I want my plugin to check "Lighting" to see if there is already an item that is a "Sky"

If there isn't already a sky in Lighting, I will add one.

Here's what I have...

Sky = Instance.new("Sky", game.Lighting) Sky.Name = SmartSky -- Adds a Sky named SmartSky

But how would I see if there's already another Sky in lighting. If there is, I don't want to create another. I just want to rename the one that's already there to "SmartSky"

If you understand what i'm looking for, please feel free to answer...

1 answer

Log in to vote
1
Answered by
samfun123 235 Moderation Voter
7 years ago

found = false for _,v in pairs(game:GetService("Lighting"):GetChildren()) do if v:IsA("Sky") then found = true end end

Found is going to be whether or not a "Sky" is in Lighting

Ad

Answer this question