Is it possible to change the skybox asset link in a script?

I would also like to know if it was possible to change the skybox for different players, maybe use a local script?

3 Likes

You mean every player has a different skybox or like different “places” different skies? [like psx]

2 Likes

There is the script for you:
Put it in a local script, Set Parent to game.StarterGui
Make it different each players

Code:

local sky = Instance.new("Sky")
sky.Parent = game.Lighting

sky.SunTextureId = "" --Sun Texture
sky.MoonTextureId = "" --Moon Texture
sky.SkyboxBk = "" --Back Texture
sky.SkyboxDn = "" --Down Texture
sky.SkyboxFt = "" --Front Texture
sky.SkyboxLf = "" --Left Texture
sky.SkyboxRt = "" --Right Texture
sky.SkyboxUp = "" --Up Texture
2 Likes

If the values are set then it sets the sky the same on every client but not on server so whats the point?:skull:
Like i get what your talking about but we neeed numbervalues for every side texture and moon/sun and make those different for the client and use the numbervalues.value to make the sky

1 Like

I’m thinking of a lobby with a white skybox to make a snow type effect while in the main game I was planning to make a more realistic one

1 Like

I assume it is possible to do client-side as I’ve seen it being used on games like CHESS! by CookieScript. The code is probably similar to what @fares14213 sent. I assume a more compact version is the following(assuming every sky texture is going to be the same):

local sky = Instance.new("Sky", game.Lighting)

local asset = "the asset rbxassetid" 

for _, name in pairs({"Bk", "Dn", "Ft", "Lf", "Rt", "Up"}) do
	sky["Skybox"..name] = asset
end

asset doesn’t need to be a hardcoded constant in the script, it can be a client variable from client in-game settings for example.

1 Like

Is it possible to make two separate skies and place it somewhere, such as StarterGUI or something, in a script? As I said to someone else, there would be a lobby and a main game and some players would be in those locations at the same time.

I assume it is, however for that to work you will most likely have to destroy the old sky in Lighting if it exists before adding the new one.

Where would I parent it to specific players? If it was in lighting it would affect the whole server right?

If you did it on the client(through a LocalScript) no, remember clients can’t replicate changes they make to the server except of very specific scenarios like character movement.

you can quickly test that by swapping your view to client/server during a test on the Roblox studio view tab.

1 Like

Do skies only work on Lighting?

I think so, pretty sure all the devs parent them under Lighting.

Then it isn’t possible to have different skies for different players in the same server, which means I would have to resort to changing values, which doesn’t work as well according to what you said.

No, it is, that’s the purpose of the client-server model. When you make a change for a client it won’t replicate to the server meaning that other players skybox won’t change and a sky won’t be parented to Lighting from their perspective.

1 Like