Some Skybox Help

Hello. I need some help with my Skybox System.

Currently, I am working on a game. I have made a settings menu with buttons inside it. I want to create a button which, every time you press it, it will change the skybox to a night skybox (if you currently are having a day skybox) and to a day skybox (if you currently are having a night skybox).

Here is a screenshot of my settings menu:

(The third button is my change skybox button)

I have attached a script inside of my change skybox button gui, here it is:
Screenshot (186)

The script I attached above is my script, which just doesn’t seem to work. Does anybody know why?

If you do, please reply, I would really appreciate if you do. Thank you so much.

Are you sure “Change Skybox :N ight” isn’t a typo? Is it supposed to be “Change Skybox: Night”?

Did you forgot to add “http://www.roblox.com/asset/?id=” ?

script.Parent.MouseButton1Click:Connect(function()
	if script.Parent.Text == "Change Skybox: Day" then
		game.Lighting.Sky.SkyboxBk = "http://www.roblox.com/asset/?id=147590803"
		game.Lighting.Sky.SkyboxDn = "http://www.roblox.com/asset/?id=147590803"
		game.Lighting.Sky.SkyboxFt = "http://www.roblox.com/asset/?id=147590803"
		game.Lighting.Sky.SkyboxLf = "http://www.roblox.com/asset/?id=147590803"
		game.Lighting.Sky.SkyboxRt = "http://www.roblox.com/asset/?id=147590803"
		game.Lighting.Sky.SkyboxUp = "http://www.roblox.com/asset/?id=147590803"
		script.Parent.Text = "Change Skybox: Night"
	elseif script.Parent.Text == "Change Skybox: Night" then
		game.Lighting.Sky.SkyboxBk = "http://www.roblox.com/asset/?id=81130614"
		game.Lighting.Sky.SkyboxDn = "http://www.roblox.com/asset/?id=81130614"
		game.Lighting.Sky.SkyboxFt = "http://www.roblox.com/asset/?id=81130614"
		game.Lighting.Sky.SkyboxLf = "http://www.roblox.com/asset/?id=81130614"
		game.Lighting.Sky.SkyboxRt = "http://www.roblox.com/asset/?id=81130614"
		game.Lighting.Sky.SkyboxUp = "http://www.roblox.com/asset/?id=81130614"
		script.Parent.Text = "Change Skybox: Day"
	end
end)
1 Like

Here is a bit tidier way to set the skybox textures. Seeming that you’re using the same Id for the skybox properties, you can just turn that in to a 1 parameter function. Like so:

local SkyboxProperties = {"SkyboxBk","SkyboxFt","SkyboxDn","SkyboxLf","SkyboxRt","SkyboxUp"}
local SkyboxIDs = {
	["Night"]=147590803,
	["Day"]=81130614, -- (this id you're using a model, needs to be an image id.)
}
function changeSky(id) -- Change skybox to "id"
	for _,prop in pairs(SkyboxProperties) do
		game.Lighting.Sky[prop]="rbxassetid://"..tostring(id)
	end
end

script.Parent.MouseButton1Click:Connect(function()
	if (script.Parent.Text == "Change Skybox: Day") then
		changeSky(SkyboxIDs.Night)
		script.Parent.Text = "Change Skybox: Night"
	else
		changeSky(SkyboxIDs.Day)
		script.Parent.Text = "Change Skybox: Day"
	end
end)
1 Like

Thank you so much, I tried using your method and it ended up working. I am so excited that my button finally worked, thank you so much my guy :blush:

1 Like