Skybox and Atmopshere change locally while inside a part

How do I make my skybox & atmosphere change locally when I go inside of a part?

Here’s an example, if Player1 is in level 1, the skybox would be a blue sky and atmosphere would be not that foggy. Then Player1 goes to level 2, the skybox changes to a desert and the atmosphere changes to a bit foggier.

After that, Player2 joins and is on level 1, with the same blue skybox and atmosphere because they are on level 1.

1 Like

In a local script in StarterCharacterScripts

local part = workspace:WaitForChild("Level2Part")
local player = game.Players.LocalPlayer

part.Touched:Connect(function(hit)
  local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
  if hitPlayer and hitPlayer == player then
    -- change atmosphere and sky
  end
end)

so, for the atmosphere and sky would I put
game.ServerStorage.Atmosphere2
game.ServerStorage.SkyLevel2

game.ServerStorage.Atmosphere2.Enabled = true
game.ServerStorage.SkyLevel2.Enabled = true
2 Likes

How do I make it false when I go to another part? Like Level3

1 Like
local player = game.Players.LocalPlayer
local part1 = workspace:WaitForChild("Level1Part")
local part2 = workspace:WaitForChild("Level2Part")
local part3 = workspace:WaitForChild("Level3Part")

function changeSky(hit, number)
  local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
  if hitPlayer and hitPlayer == player then
    game.ServerStorage.["Atmosphere"..number].Enabled = true
    game.ServerStorage.["SkyLevel"..number].Enabled = true
  end
end)

part1.Touched:Connect(function(hit)
  changeSky(hit, 1)
end)
part2.Touched:Connect(function(hit)
  changeSky(hit, 2)
end)
part3.Touched:Connect(function(hit)
  changeSky(hit, 3)
end)

Make sure you have each sky have the right number afterwards

1 Like

Wait, theres no Enabled or Disabled property for skies or atmospheres???

What do I do now lol

1 Like

You can insert atmosphere into “Lightning”.
Nevermind they both don’t have enabled or disabled property.

Alrighty, I’ll try that once Im on lunch break lol.

1 Like

Have you solved the problem yet? I have to same problem, and I got something for you, (at least for getting inside the part)

edit: nevermind, you already got help for that part

1 Like

I actually never solved it, or tried it yet- I forgot and I don’t think there’s really any way I guess.

1 Like

I know there is a way because ive seen my friend do it, but he wont leak me the script

1 Like

Side note: You can’t access the ServerStorage in a LocalScript

Put it inside ReplicatedStorage instead, that way it’ll be replicated across both the server/client

local player = game.Players.LocalPlayer
local part1 = workspace:WaitForChild("Level1Part")
local part2 = workspace:WaitForChild("Level2Part")
local part3 = workspace:WaitForChild("Level3Part")

function changeSky(hit, number)
  local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
  if hitPlayer and hitPlayer == player then
    game.ReplicatedStorage.["Atmosphere"..number].Enabled = true
    game.ReplicatedStorage.["SkyLevel"..number].Enabled = true
  end
end)

part1.Touched:Connect(function(hit)
  changeSky(hit, 1)
end)
part2.Touched:Connect(function(hit)
  changeSky(hit, 2)
end)
part3.Touched:Connect(function(hit)
  changeSky(hit, 3)
end)
1 Like

no enabled or disabled feature in skies or atmosphere

1 Like

If you’re wanting to change the Skybox and Atmosphere, chances are you’ll probably need to add multiple separate Skyboxes inside ReplicatedStorage & adjust the settings of the Lighting properties if you want to change it from the local standpoint whenever a part gets touched

Perhaps something like this inside a LocalScript? (Adding onto Dandcx’s code)

local Player = game.Players.LocalPlayer
local Part1 = workspace:WaitForChild("Change1")
local Part2 = workspace:WaitForChild("Change2")
local PartDebounce = false

function ChangeThings(HitPart, NumberChange)
    local Player = game.Players:GetPlayerFromCharacter(HitPart.Parent)
    if Player and PartDebounce == false then
        PartDebounce = true

        for _, Skybox in pairs(game.Lighting:GetChildren()) do
            if Skybox:IsA("Skybox") then
               Skybox:Destroy()
            end
        end
        if NumberChange == 1 then
            local SkyboxClone = game.ReplicatedStorage.Skybox1:Clone()
            SkyboxClone.Parent = game.Lighting
            --Change other lighting properties here
        elseif NumberChange == 2 then
            local SkyboxClone = game.ReplicatedStorage.Skybox2:Clone()
            SkyboxClone.Parent = game.Lighting
            --Change other lighting properties here
        end
        wait(3)
        PartDebounce = false
    end
end

Part1.Touched:Connect(function(Hit)
    ChangeThings(Hit, 1)
end)

Part2.Touched:Connect(function(Hit)
    ChangeThings(Hit, 2)
end)
3 Likes

Problem with this: It changes globally for my game. If someone is in a specific area, the atmosphere and skybox changes for everyone, despite it being a local script in the character. Here’s my code.

local Player = game.Players.LocalPlayer
local Part1 = game.Workspace:WaitForChild("ExcaliburDimensionBox")
local Part2 = game.Workspace:WaitForChild("DefaultMap")
local Part3 = game.Workspace:WaitForChild("InfiniteAzure")
local PartDebounce = false

function ChangeThings(HitPart, NumberChange)
    local Player = game.Players:GetPlayerFromCharacter(HitPart.Parent)
    if Player and PartDebounce == false then
        PartDebounce = true

        for _, Skybox in pairs(game.Lighting:GetChildren()) do
            if Skybox:IsA("Skybox") then
                Skybox:Destroy()
            end
        end
        if NumberChange == 1 then
            local SkyboxClone = game.ReplicatedStorage.SkyEx:Clone()
            SkyboxClone.Parent = game.Lighting
            local AtmosphereClone = game.ReplicatedStorage.AtmosphereEx:Clone()
            AtmosphereClone.Parent = game.Lighting
            game.Workspace.CurrentMusic.Volume = 0
            game.Workspace.ExcaliburDimension.Volume = 0.3
            if game.Workspace.ExcaliburDimension.IsPlaying == false then
            game.Workspace.ExcaliburDimension:Play()
            end
            --Change other lighting properties here
        elseif NumberChange == 2 then
            local SkyboxClone = game.ReplicatedStorage.SkyDefault:Clone()
            SkyboxClone.Parent = game.Lighting
            local AtmosphereClone = game.ReplicatedStorage.AtmosphereDefault:Clone()
            AtmosphereClone.Parent = game.Lighting
            game.Workspace.CurrentMusic.Volume = 0.3
            game.Workspace.ExcaliburDimension.Volume = 0
            game.Workspace.InfiniteAzureBGM.Volume = 0
            game.Workspace.ExcaliburDimension:Stop()
            game.Workspace.InfiniteAzureBGM:Stop()
            --Change other lighting properties here
        elseif NumberChange == 3 then
            local SkyboxClone = game.ReplicatedStorage.SkyInfiniteAzure:Clone()
            SkyboxClone.Parent = game.Lighting
            local AtmosphereClone = game.ReplicatedStorage.AtmosphereEx:Clone()
            AtmosphereClone.Parent = game.Lighting
            game.Workspace.CurrentMusic.Volume = 0
            game.Workspace.InfiniteAzureBGM.Volume = 0.3
            if game.Workspace.InfiniteAzureBGM.IsPlaying == false then
            game.Workspace.InfiniteAzureBGM:Play()
            end
            --Change other lighting properties here
        end
        task.wait()
        PartDebounce = false
    end
end

Part1.Touched:Connect(function(Hit)
    ChangeThings(Hit, 1)
end)

Part2.Touched:Connect(function(Hit)
    ChangeThings(Hit, 2)
end)

Part3.Touched:Connect(function(Hit)
    ChangeThings(Hit, 3)
end)
2 Likes