Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

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)

This discussion is preserved as it was. New answers, comments, and votes are closed.