I’ve been trying to figure out how to switch the skybox using a script but have come up with no luck. Hopefully some much smarter people can help me out.
I have the skyboxes in a folder under the script (script.Skyboxes), and the script is trying to replace the desert skybox with the arctic one.
local lighting = game:GetService("Lighting")
local function skyArctic()
script.Skyboxes.ArcticSky.Parent = lighting
lighting.DesertSky.Parent = script.Skyboxes
end
skyArctic()
Tried everything I can think of, but no luck. Any help is appreciated!
I ran your script and it worked perfectly fine. Is the script a local or server script and where in the game is the script stored?
1 Like
Here’s what I would personally do just for an easier reference:
-
If you don’t have a huge quantity of the same Skyboxes, you can create variables for those so that you can easily Parent them whenever they’re needed
-
It depends on what type of script you’re doing this on, something like a LocalScript
can’t run under specific circumstances
-
It also depends where you put the script, it seems like it would just run fine if you place it inside ServerScriptService
local Lighting = game:GetService("Lighting")
local Skyboxes -- Where the Skyboxes are aaaa
local ArcticSky -- Location of where the ArcticSky Skybox is
local DesertSky -- Location of where the DesertSky Skybox is
local function skyArctic()
DesertSky.Parent = Skyboxes
ArcticSky.Parent = Lighting
end
skyArctic()
5 Likes
The script is a server script and its in ServerStorage
1 Like
worked perfectly fine for me, are there any errors in output?
1 Like
@samthepilot17 @ItzBloxyDev Just for reference:
The only known instances where Scripts can fully & properly run that I know of, are:
ServerScriptService
-
workspace
(This includes both Local & Server Scripts)
-
ReplicatedFirst
(Local)
-
StarterPlayer/CharacterScripts
(Local)
-
StarterGui
(Local)
2 Likes
Oh, sry I read the thing wrong, I thought he meant server script storage
1 Like