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 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)