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

How do I make this script change two folders with parts in it at once?

Asked by 6 years ago

I'm trying to make a computer, and I want it so when it gets turned on the screen turns white, and some lights turn lime green, but only the button changes (it's in the lights folder) to lime green, but the screen doesn't turn on, and the other lights don't turn on...

script.Parent.ClickDetector.MouseClick:Connect(function()
    if script.Parent.Value.Value == false then
        script.Parent.Value.Value = true
        for _,v in pairs(script.Parent.Parent.Parent.Screen:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Neon
                v.BrickColor = BrickColor.new("Institutional white")
                v.SurfaceLight.Enabled = true
            end
        end
    game.Lighting.FogEnd = 100000
    else
        script.Parent.Value.Value = false
        for _,v in pairs(script.Parent.Parent.Parent.Screen:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Glass
                v.BrickColor = BrickColor.new("Black")
                v.SurfaceLight.Enabled = false
wait(.2)             
        end
        end
    end
end)

script.Parent.ClickDetector.MouseClick:Connect(function()
    if script.Parent.Value.Value == false then
        script.Parent.Value.Value = true
        for _,v in pairs(script.Parent.Parent.Parent.Lights:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Neon
                v.BrickColor = BrickColor.new("Lime green")
                v.SurfaceLight.Enabled = true
            end
        end
    game.Lighting.FogEnd = 100000
    else
        script.Parent.Value.Value = false
        for _,v in pairs(script.Parent.Parent.Parent.Screen:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Glass
                v.BrickColor = BrickColor.new("Black")
                v.SurfaceLight.Enabled = false
wait(.2)             
        end
        end
    end
end)

This is all of my script, and I'm a bit of a noob, so please go easy on me!

1 answer

Log in to vote
0
Answered by
LeadRDRK 437 Moderation Voter
6 years ago

Try this:

script.Parent.ClickDetector.MouseClick:Connect(function()
    if script.Parent.Value.Value == false then
        script.Parent.Value.Value = true
        for _,v in pairs(script.Parent.Parent.Parent.Screen:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Neon
                v.BrickColor = BrickColor.new("Institutional white")
                v.SurfaceLight.Enabled = true
            end
        end
        for _,v in pairs(script.Parent.Parent.Parent.Lights:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Neon
                v.BrickColor = BrickColor.new("Lime green")
                v.SurfaceLight.Enabled = true
            end
        end
        game.Lighting.FogEnd = 100000
    else
        script.Parent.Value.Value = false
        for _,v in pairs(script.Parent.Parent.Parent.Screen:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Glass
                v.BrickColor = BrickColor.new("Black")
                v.SurfaceLight.Enabled = false
                wait(.2)
            end
        end
        for _,v in pairs(script.Parent.Parent.Parent.Screen:GetChildren()) do
            if v:IsA("BasePart") then
                v.Material = Enum.Material.Glass
                v.BrickColor = BrickColor.new("Black")
                v.SurfaceLight.Enabled = false
                wait(.2)
            end
        end
    end
end)

Ad

Answer this question