I mean like create a button with ClickDetector and when I click it changes the sky into an ID that I put in.
✓ ANSWER ACCEPTED
How do I change the sky with clicking a button?
2 answers
✓ Accepted answer
Try this! Put this inside a part in workspace. Put this script inside a clickdetector in the part: Part>ClickDetector/Sky1/Sky2>Script
local Part = script.Parent
local Sky1 = script.Parent:FindFirstChild("YOURSKYMODELHERE")
local Sky2 = script.Parent:FindFirstChild("YOURSKYMODELHERE")
local Toggle = false
script.Parent.MouseClick:Connect(function()
if Toggle == false then
local Clone = Sky1:Clone()
Clone.Parent = game.Lighting
local Other = game.Lighting:FindFirstChild(Sky2.Name)
if Other then
Other:Destroy()
end
else
local Clone = Sky2:Clone()
Clone.Parent = game.Lighting
local Other = game.Lighting:FindFirstChild(Sky1.Name)
if Other then
Other:Destroy()
end
end
end)
All you have to do is put two of your skys (put the ID in them too) into the part and put the names in the script! Enjoy!
You could delete and replace the sky with another you have stored somewhere
function OnClick()
game.Lighting.Sky:Destroy()
local SkyClone = game.ServerStorage.SkyReplacement:Clone()
SkyClone.Parent = game.Lighting
SkyClone.Name = "Sky"
end
Or just set each part of the sky
function OnClick
game.Lighting.Sky.Top = -- Roblox Image URL --
game.Lighting.Sky.Bottom = -- Roblox Image URL --
-- etc. --
end
This discussion is preserved as it was. New answers, comments, and votes are closed.
