How to change sky when map is loaded into workplace?

Hello! Currently, I have a script for when a player touches a part it changes the sky. It works! but not all the time. I figure it would be easier to activate when a script sees that “insert map here” has been added to the workplace. How would I go about doing this?

Here is the current script I am using:

local Lighting = game:GetService("Lighting")
local Skyboxes = game.Lighting.Skies
local DefaultSky = game.Lighting.Spawn
local SFOTHSky = game.Lighting.Skies.SFOTH

local ServerStorage = game:GetService("ServerStorage") --Use ServerStorage instead of lighting!
local Players = game:GetService("Players")
local Tool = game.ServerStorage.Tools.Class

script.Parent.Touched:Connect(function()
	task.wait(1.5)
	game.SoundService.TheGreatStrategy.Playing = false
	game.SoundService.SFOTHTheme.Playing = true
	local function skyChange()
		SFOTHSky.Parent = Lighting
		DefaultSky.Parent = Skyboxes
		
		end
	skyChange()	
end)

Thanks for any help!!!

You can use the game.Workspace.ChildAdded event. If I understand you correctly.
Example:

game.Workspace.ChildAdded:Connect(function(child)
	if child.Name == "model name or something" then
		--map added to workspace
	end
end)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.