#skybox changes in specific areas

1 messages · Page 1 of 1 (latest)

magic light
#

im tryna make it so the skybox and music changes when a player is in a specific area. i already got the music part down but i dont know how to do the skybox, can any1 help? (client sided)

stray sluice
#

Hey

#

I'll help y

#

**So To make the Skybox change client-side when a player enters a specific area, you'll want to do the following:

  • LocalScript inside StarterPlayerScripts.

  • Touched or Region3 or ZonePlus to detect the area.

  • Custom Sky instance for your new skybox.

  • Client-side only (to not affect all players).**

#

So I'll give you quickest methode

#

**1. In Workspace:
Add an invisible, non-collidable Part (e.g., called "SkyTrigger") that marks the area.

  1. In ReplicatedStorage:
    Add a Sky object with your custom skybox images., and name it "CustomSky"**
#

and this is the LocalScript must be in (StarterPlayerScripts):

#
local trigger = workspace:WaitForChild("SkyTrigger")
local customSky = game.ReplicatedStorage:WaitForChild("CustomSky"):Clone()

local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera

local inZone = false

trigger.Touched:Connect(function(hit)
    if hit.Parent == player.Character and not inZone then
        inZone = true
        for _, v in pairs(cam:GetChildren()) do
            if v:IsA("Sky") then v:Destroy() end
        end
        customSky:Clone().Parent = cam
    end
end)

trigger.TouchEnded:Connect(function(hit)
    if hit.Parent == player.Character then
        inZone = false
        for _, v in pairs(cam:GetChildren()) do
            if v:IsA("Sky") then v:Destroy() end
        end
    end
end)
magic light
#

thank you so much bro ill try it out

stray sluice
#

You're Welcome, this is my job 😉

magic light
meager sirenBOT
#

studio** You are now Level 1! **studio

stray sluice
#

ZonePlus is a free Roblox module (not a plugin) you can add to your game by importing it from the Roblox library (Marketplace) or via its official page.

#

How to use:

#

1. Insert ZonePlus ModuleScript into ReplicatedStorage.

#

2. Require it in your server or local scripts:

local ZonePlus = require(game.ReplicatedStorage.ZonePlus)

3. Define zones by size and position, then listen to .Touched, .SteppedIn, .SteppedOut events per player.

magic light
stray sluice
#

**# No, that line :
should not go in a LocalScript inside StarterPlayerScripts by default, it depends on where and how you want to use ZonePlus:

  • If you want to detect zones for a single player on their client only (client-side detection), then yes, put that line in a LocalScript inside StarterPlayerScripts or similar client context.

  • If you want to do zone detection on the server for all players globally (server-side logic), then put that line in a Script in ServerScriptService or wherever your server scripts run.**

magic light
#

sorry just gotta make sure im doing this right

stray sluice
#

** # Exactly! For client-sided detection and effects, your setup in StarterPlayerScripts would look like this:

  • One LocalScript for handling the ZonePlus zone detection, this script requires the ZonePlus module and detects when the player enters or leaves the zone.

  • Another LocalScript (or part of the same script) for changing the Skybox and playing music when the player is inside that zone.**

magic light
#

these are the 2 scripts im using, but for some reason it isnt working
i did name the part SkyTrigger, is there anything i need to add to one of these codes or change in the original ZonePlus scripts?

stray sluice
#

can you give me the output errors?

#

wait

meager sirenBOT
#

studio** You are now Level 7! **studio

stray sluice
#

You're not using ZonePlus at all , you're still relying on basic .Touched, which is unreliable for player detection and doesn't work consistently with HumanoidRootPart or characters due to physics glitches.

#

I'll code u wokring script

magic light
#

oh

#

thank you

stray sluice
#

ur welcome

#
local ZonePlus = require(game.ReplicatedStorage:WaitForChild("ZonePlus"))
local triggerPart = workspace:WaitForChild("SkyTrigger")
local customSky = game.ReplicatedStorage:WaitForChild("CustomSky")
local player = game.Players.LocalPlayer
local cam = workspace.CurrentCamera

local zone = ZonePlus.new(triggerPart)

zone.playerEntered:Connect(function(localPlayer)
    if localPlayer == player then
        for _, v in pairs(cam:GetChildren()) do
            if v:IsA("Sky") then v:Destroy() end
        end
        customSky:Clone().Parent = cam
    end
end)

zone.playerExited:Connect(function(localPlayer)
    if localPlayer == player then
        for _, v in pairs(cam:GetChildren()) do
            if v:IsA("Sky") then v:Destroy() end
        end
    end
end)
#

Try it now, should works now

magic light
#

it says this

#

btw if u ever need i can send a video

stray sluice
#

mmm, let me check and analyze the errors

magic light
meager sirenBOT
#

studio** You are now Level 2! **studio

stray sluice
#

sorry, I was offline

#

I knew the probelm

#

Your script is waiting forever for the ZonePlus module because it does not exist (or is misnamed) in ReplicatedStorage!!

#

Make sure in ReplicatedStorage a ModuleScript named exactly ZonePlus

#

(spelled exactly, with uppercase Z and P)

#

Click “Get” → it will go to your toolbox.

#

In Studio, open the Toolbox → drag the ZonePlus module into ReplicatedStorage.