Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I change the sky with clicking a button?

Asked by 4 years ago

I mean like create a button with ClickDetector and when I click it changes the sky into an ID that I put in.

2 answers

Log in to vote
0
Answered by
haba_nero 386 Moderation Voter
4 years ago

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!

Ad
Log in to vote
0
Answered by
Benbebop 1049 Moderation Voter
4 years ago

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

Answer this question