#blackout script

4 messages · Page 1 of 1 (latest)

oblique magnet
#
  • dont use global variables
  • learn what indents are
  • use guard clauses
#
  • u are using table.find with switched arguments
#
enabled = false
lighttypes = {
    "PointLight",
    "SpotLight",
    "SurfaceLight",
}
function blackout()
    enabled = true
    game.SoundService.blackout:Play()
    wait(0.3)

    local lights = game.Workspace.Lights:GetDescendants()
    for i = 1, #lights do
        local light = lights[i]
        if enabled == true then
            game.Lighting.Ambient = Color3.fromRGB(0,0,0)
            game.Lighting.OutdoorAmbient = Color3.fromRGB(32,32,32)
        
            if table.find(lighttypes, light.ClassName) then
                light.Enabled = false
            end
            enabled = false
        else
            game.Lighting.Ambient = Color3.fromRGB(128,128,128)
            game.Lighting.OutdoorAmbient = Color3.fromRGB(128,128,128)
            if table.find(lighttypes, light.ClassName) then
                light.Enabled = true
            end
            enabled = true
        end
    end
end

game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        if message == ".bo" then
            print("Oops!")
            blackout()
        end
    end)
end)
oblique magnet
#

lol