OiHub Optimize games
Key RequiredUniversal

OiHub Optimize games

Universal Scriptcrazyx0910crazyx0910 2K views 1.6K executesUpdated Sep 13, 2025
Unrated
00
Lua Script•369 lines (13711 chars)
-- OiHub Optimize (corrigido) - LocalScript
-- Colocar em StarterPlayerScripts

local KEY = "OiHub_Key10"
local DiscordLink = "https://discord.gg/EYSvDJGc"

local Players = game:GetService("Players")
local StarterGui = game:GetService("StarterGui")
local RunService = game:GetService("RunService")
local UserInputService = game:GetService("UserInputService")

local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")

-- BoolValues persistentes no player
local function ensureBool(name, default)
    local v = player:FindFirstChild(name)
    if not v then
        v = Instance.new("BoolValue")
        v.Name = name
        v.Value = default and true or false
        v.Parent = player
    end
    return v
end

local optimizedFlag = ensureBool("OiHubOptimized", false)
local closedFlag = ensureBool("OiHubClosed", false)

-- Se o usuário já fechou o GUI anteriormente com X, não recria
if closedFlag.Value then
    return
end

-- util
local function notify(txt, dur)
    pcall(function()
        StarterGui:SetCore("SendNotification", {Title="OiHub", Text = tostring(txt), Duration = dur or 3})
    end)
end

-- Helpers para attributes (string/number/bool)
local function setAttr(inst, key, val)
    if inst and inst.SetAttribute then
        pcall(function() inst:SetAttribute(key, val) end)
    end
end
local function getAttr(inst, key)
    if inst and inst.GetAttribute then
        local ok, v = pcall(function() return inst:GetAttribute(key) end)
        if ok then return v end
    end
    return nil
end

-- Aplica otimização: muda materiais para Plastic e desliga VFX (salvando originais em attributes)
local function applyOptimization()
    for _, obj in ipairs(workspace:GetDescendants()) do
        -- BasePart: salva material e muda para Plastic
        if obj:IsA("BasePart") then
            if not getAttr(obj, "OiHub_origMaterial") then
                setAttr(obj, "OiHub_origMaterial", tostring(obj.Material))
            end
            -- não muda transparency nem remove objetos, só altera material
            pcall(function() obj.Material = Enum.Material.Plastic end)
        end

        -- ParticleEmitter
        if obj:IsA("ParticleEmitter") then
            if getAttr(obj, "OiHub_origEnabled") == nil then
                setAttr(obj, "OiHub_origEnabled", obj.Enabled and true or false)
                -- Rate é NumberRange: guardamos min e max
                local r = obj.Rate
                local minv, maxv = 0, 0
                if r then
                    pcall(function() minv = r.Min; maxv = r.Max end)
                end
                setAttr(obj, "OiHub_origRateMin", minv)
                setAttr(obj, "OiHub_origRateMax", maxv)
            end
            pcall(function() obj.Enabled = false; obj.Rate = NumberRange.new(0) end)
        end

        -- Trail
        if obj:IsA("Trail") then
            if getAttr(obj, "OiHub_origEnabled") == nil then
                setAttr(obj, "OiHub_origEnabled", obj.Enabled and true or false)
            end
            pcall(function() obj.Enabled = false end)
        end

        -- Beam
        if obj:IsA("Beam") then
            if getAttr(obj, "OiHub_origEnabled") == nil then
                setAttr(obj, "OiHub_origEnabled", obj.Enabled and true or false)
            end
            pcall(function() obj.Enabled = false end)
        end

        -- Smoke / Fire
        if obj:IsA("Smoke") or obj:IsA("Fire") then
            if getAttr(obj, "OiHub_origEnabled") == nil then
                setAttr(obj, "OiHub_origEnabled", obj.Enabled and true or false)
            end
            pcall(function() obj.Enabled = false end)
        end

        -- Light types: PointLight, SpotLight, SurfaceLight -> desligar mas salvar
        if obj:IsA("PointLight") or obj:IsA("SpotLight") or obj:IsA("SurfaceLight") then
            if getAttr(obj, "OiHub_origEnabled") == nil then
                setAttr(obj, "OiHub_origEnabled", obj.Enabled and true or false)
                setAttr(obj, "OiHub_origBrightness", obj.Brightness or 0)
                setAttr(obj, "OiHub_origRange", obj.Range or 0)
            end
            pcall(function() obj.Enabled = false; obj.Brightness = 0; obj.Range = 0 end)
        end

        -- Sound: abaixa volume mas NÃO remove (salva)
        if obj:IsA("Sound") then
            if getAttr(obj, "OiHub_origVolume") == nil then
                setAttr(obj, "OiHub_origVolume", obj.Volume or 1)
                setAttr(obj, "OiHub_origPlaying", obj.IsPlaying and true or false)
            end
            pcall(function() obj.Volume = 0; obj:Stop() end)
        end
    end

    -- marca flag persistente
    optimizedFlag.Value = true
    notify("Otimização aplicada (materiais → Plastic e VFX desativados).", 3)
end

-- Restaura lendo os attributes salvos
local function restoreOptimization()
    for _, obj in ipairs(workspace:GetDescendants()) do
        -- BasePart material
        if obj:IsA("BasePart") then
            local matName = getAttr(obj, "OiHub_origMaterial")
            if matName then
                local ok, enumMat = pcall(function() return Enum.Material[matName] end)
                if ok and enumMat then
                    pcall(function() obj.Material = enumMat end)
                else
                    -- fallback: set to SmoothPlastic
                    pcall(function() obj.Material = Enum.Material.SmoothPlastic end)
                end
                -- remove attribute
                pcall(function() obj:SetAttribute("OiHub_origMaterial", nil) end)
            end
        end

        -- ParticleEmitter restore
        if obj:IsA("ParticleEmitter") then
            local origEnabled = getAttr(obj, "OiHub_origEnabled")
            local minv = getAttr(obj, "OiHub_origRateMin")
            local maxv = getAttr(obj, "OiHub_origRateMax")
            if origEnabled ~= nil then
                pcall(function()
                    obj.Enabled = origEnabled
                    if minv and maxv then obj.Rate = NumberRange.new(minv, maxv) end
                end)
                pcall(function() obj:SetAttribute("OiHub_origEnabled", nil); obj:SetAttribute("OiHub_origRateMin", nil); obj:SetAttribute("OiHub_origRateMax", nil) end)
            end
        end

        -- Trail / Beam / Smoke / Fire restore
        if obj:IsA("Trail") or obj:IsA("Beam") or obj:IsA("Smoke") or obj:IsA("Fire") then
            local origEnabled = getAttr(obj, "OiHub_origEnabled")
            if origEnabled ~= nil then
                pcall(function() obj.Enabled = origEnabled end)
                pcall(function() obj:SetAttribute("OiHub_origEnabled", nil) end)
            end
        end

        -- Lights
        if obj:IsA("PointLight") or obj:IsA("SpotLight") or obj:IsA("SurfaceLight") then
            local origE = getAttr(obj, "OiHub_origEnabled")
            local origB = getAttr(obj, "OiHub_origBrightness")
            local origR = getAttr(obj, "OiHub_origRange")
            if origE ~= nil then
                pcall(function() obj.Enabled = origE; if origB then obj.Brightness = origB end; if origR then obj.Range = origR end end)
                pcall(function() obj:SetAttribute("OiHub_origEnabled", nil); obj:SetAttribute("OiHub_origBrightness", nil); obj:SetAttribute("OiHub_origRange", nil) end)
            end
        end

        -- Sounds
        if obj:IsA("Sound") then
            local ov = getAttr(obj, "OiHub_origVolume")
            local op = getAttr(obj, "OiHub_origPlaying")
            if ov ~= nil then
                pcall(function() obj.Volume = ov; if op then obj:Play() end end)
                pcall(function() obj:SetAttribute("OiHub_origVolume", nil); obj:SetAttribute("OiHub_origPlaying", nil) end)
            end
        end
    end

    optimizedFlag.Value = false
    notify("Visual restaurado.", 3)
end

-- GUI: (reaproveita se já existir)
local guiName = "OiHubOptimizeGUI"
local gui = playerGui:FindFirstChild(guiName)
if gui and gui:IsA("ScreenGui") then
    -- reuse
else
    gui = Instance.new("ScreenGui")
    gui.Name = guiName
    gui.ResetOnSpawn = false
    gui.Parent = playerGui
end

-- Limpa antigas instâncias internas se existirem (evita duplicações)
local function safeFind(name)
    local o = gui:FindFirstChild(name)
    if o then o:Destroy() end
end
safeFind("KeyFrame"); safeFind("MainFrame"); safeFind("RestoreBtn")

-- Key frame
local keyFrame = Instance.new("Frame", gui)
keyFrame.Name = "KeyFrame"
keyFrame.Size = UDim2.new(0, 320, 0, 160)
keyFrame.Position = UDim2.new(0.5, -160, 0.5, -80)
keyFrame.BackgroundColor3 = Color3.fromRGB(24,24,28)
Instance.new("UICorner", keyFrame).CornerRadius = UDim.new(0,8)

local kTitle = Instance.new("TextLabel", keyFrame)
kTitle.Size = UDim2.new(1, -24, 0, 28)
kTitle.Position = UDim2.new(0, 12, 0, 8)
kTitle.BackgroundTransparency = 1
kTitle.Text = "OiHub - Insira a Key"
kTitle.TextColor3 = Color3.fromRGB(230,230,230)
kTitle.Font = Enum.Font.GothamBold
kTitle.TextSize = 18

local keyBox = Instance.new("TextBox", keyFrame)
keyBox.Size = UDim2.new(0.9, 0, 0, 36)
keyBox.Position = UDim2.new(0.05, 0, 0, 44)
keyBox.PlaceholderText = "Digite a Key..."
keyBox.Text = ""
keyBox.BackgroundColor3 = Color3.fromRGB(33,33,36)
keyBox.TextColor3 = Color3.fromRGB(240,240,240)
Instance.new("UICorner", keyBox).CornerRadius = UDim.new(0,6)

local confirmBtn = Instance.new("TextButton", keyFrame)
confirmBtn.Size = UDim2.new(0.45, 0, 0, 36)
confirmBtn.Position = UDim2.new(0.05, 0, 0, 92)
confirmBtn.Text = "Confirmar"
confirmBtn.BackgroundColor3 = Color3.fromRGB(64,160,255)
confirmBtn.TextColor3 = Color3.fromRGB(255,255,255)
Instance.new("UICorner", confirmBtn).CornerRadius = UDim.new(0,6)

local getKeyBtn = Instance.new("TextButton", keyFrame)
getKeyBtn.Size = UDim2.new(0.45, 0, 0, 36)
getKeyBtn.Position = UDim2.new(0.5, 0, 0, 92)
getKeyBtn.Text = "Get Key"
getKeyBtn.BackgroundColor3 = Color3.fromRGB(80,80,80)
getKeyBtn.TextColor3 = Color3.fromRGB(255,255,255)
Instance.new("UICorner", getKeyBtn).CornerRadius = UDim.new(0,6)

-- Main: botão otimizar único + minimizar + fechar
local mainFrame = Instance.new("Frame", gui)
mainFrame.Name = "MainFrame"
mainFrame.Size = UDim2.new(0, 320, 0, 120)
mainFrame.Position = UDim2.new(0.5, -160, 0.5, -60)
mainFrame.BackgroundColor3 = Color3.fromRGB(29,29,32)
mainFrame.Visible = false
Instance.new("UICorner", mainFrame).CornerRadius = UDim.new(0,8)

local closeBtn = Instance.new("TextButton", mainFrame)
closeBtn.Size = UDim2.new(0, 28, 0, 28)
closeBtn.Position = UDim2.new(1, -34, 0, 6)
closeBtn.Text = "X"
closeBtn.BackgroundColor3 = Color3.fromRGB(180,60,60)

local miniBtn = Instance.new("TextButton", mainFrame)
miniBtn.Size = UDim2.new(0, 28, 0, 28)
miniBtn.Position = UDim2.new(1, -70, 0, 6)
miniBtn.Text = "-"
miniBtn.BackgroundColor3 = Color3.fromRGB(100,100,100)

local optimizeBtn = Instance.new("TextButton", mainFrame)
optimizeBtn.Size = UDim2.new(0.9, 0, 0, 60)
optimizeBtn.Position = UDim2.new(0.05, 0, 0.25, 0)
optimizeBtn.Text = "Otimizar (materiais → Plastic + VFX off)"
optimizeBtn.TextWrapped = true
optimizeBtn.BackgroundColor3 = Color3.fromRGB(64,160,255)
Instance.new("UICorner", optimizeBtn).CornerRadius = UDim.new(0,6)

-- Restore small button (aparece quando minimize)
local restoreBtn = Instance.new("TextButton", gui)
restoreBtn.Name = "RestoreBtn"
restoreBtn.Size = UDim2.new(0, 110, 0, 36)
restoreBtn.Position = UDim2.new(0.05, 0, 0.9, 0)
restoreBtn.Text = "Abrir OiHub"
restoreBtn.Visible = false
restoreBtn.BackgroundColor3 = Color3.fromRGB(64,160,255)
Instance.new("UICorner", restoreBtn).CornerRadius = UDim.new(0,6)

-- Button behaviors
confirmBtn.MouseButton1Click:Connect(function()
    if keyBox.Text == KEY then
        keyFrame.Visible = false
        mainFrame.Visible = true
        restoreBtn.Visible = false
        notify("Key aceita!", 2)
    else
        notify("Key inválida!", 2)
    end
end)

getKeyBtn.MouseButton1Click:Connect(function()
    pcall(function() setclipboard(DiscordLink) end)
    notify("Link copiado!", 2)
end)

optimizeBtn.MouseButton1Click:Connect(function()
    if not optimizedFlag.Value then
        applyOptimization()
        optimizeBtn.Text = "Restaurar visual"
    else
        restoreOptimization()
        optimizeBtn.Text = "Otimizar (materiais → Plastic + VFX off)"
    end
end)

-- Minimizar
miniBtn.MouseButton1Click:Connect(function()
    mainFrame.Visible = false
    restoreBtn.Visible = true
end)
restoreBtn.MouseButton1Click:Connect(function()
    mainFrame.Visible = true
    restoreBtn.Visible = false
end)

-- Fechar (X) destrói GUI e marca closedFlag
closeBtn.MouseButton1Click:Connect(function()
    -- se otimizado, preservamos o estado otimizadoFlag, mas removemos GUI
    gui:Destroy()
    closedFlag.Value = true
    notify("OiHub fechado. Para abrir novamente reinicie o script.", 3)
end)

-- reaplica otimização automaticamente após respawn se flag persistente estiver true
player.CharacterAdded:Connect(function()
    task.wait(0.2)
    if optimizedFlag.Value then
        -- reaplicar: se attributes já existem, applyOptimization só assegura os estados atuais (não sobrescreve atributos)
        applyOptimization()
    end
end)

-- Se já estava otimizado antes de abrir o script, aplica imediatamente
if optimizedFlag.Value then
    -- esconde key e mostra main
    keyFrame.Visible = false
    mainFrame.Visible = true
    optimizeBtn.Text = "Restaurar visual"
    -- reaplica alterações (safe)
    task.defer(function() applyOptimization() end)
else
    -- se não otimizado, show key frame (ou main se quiser)
    keyFrame.Visible = true
    mainFrame.Visible = false
end

notify("OiHub pronto. Insira a key para habilitar o botão de otimização.", 4)

Features & Information

Oihub is a script to optimize games
#jogos roblox delta script aba key desastres

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts