-- ============================================= -- CONFIGURAÇÕES GERAIS -- ============================================= local CONFIG = { TELEPORT_DELAY = 0.1, COOLDOWN_TIME = 0.3, FADE_IN = 0.1, FADE_OUT = 0.1, WEIGHT = 1, SPEED = 1, ANIMATIONS = { Z = { ID = 113307296054375, IS_TOGGLE = true, DURATION = nil, -- Duração ilimitada (toggle) AUDIO_ID = nil -- Sem áudio }, X = { ID = 99796308552916, IS_TOGGLE = false, DURATION = 1, -- 1 segundo AUDIO_ID = 87137005114358 }, C = { ID = 98727684044392, IS_TOGGLE = false, DURATION = 2, -- 2 segundos AUDIO_ID = 130758806381210 } }, AUDIO_VOLUME = 1 } -- ============================================= -- INICIALIZAÇÃO SEGURA -- ============================================= local function SafeGetService(serviceName) local success, service = pcall(function() return game:GetService(serviceName) end) return success and service or nil end -- Função auxiliar segura local function missing(t, f, fallback) if type(f) == t then return f end return fallback end cloneref = missing("function", cloneref, function(...) return ... end) -- Serviços com segurança local Services = setmetatable({}, { __index = function(_, name) return cloneref(SafeGetService(name)) end }) local ReplicatedStorage = Services.ReplicatedStorage local Players = Services.Players local UIS = Services.UserInputService local RunService = Services.RunService -- Validação dos serviços essenciais if not (ReplicatedStorage and Players and UIS) then warn("❌ Serviços essenciais não encontrados!") return end -- ============================================= -- FUNÇÕES DE ÁUDIO SEGURAS -- ============================================= local AudioModule = { -- Toca áudio para todos os jogadores PlayGlobalAudio = function(audioId, volume) if type(audioId) ~= "number" then warn("❌ Audio ID deve ser um número!") return false end local soundVolume = volume or CONFIG.AUDIO_VOLUME local success = false -- Envia para o servidor (todos ouvem) local remoteSuccess = pcall(function() local GunSoundEvent = ReplicatedStorage:FindFirstChild("RE"):FindFirstChild("1Gu1nSound1s", true) if GunSoundEvent then GunSoundEvent:FireServer(workspace, audioId, soundVolume) success = true else warn("⚠️ Evento de áudio não encontrado, tocando apenas localmente") end end) -- Toca localmente (jogador atual ouve) task.spawn(function() local player = Players.LocalPlayer if not player then return end local character = player.Character if not character then character = player.CharacterAdded:Wait() end local humanoidRootPart = character:WaitForChild("HumanoidRootPart", 5) if not humanoidRootPart then warn("❌ HumanoidRootPart não encontrado para áudio local") return end local sound = Instance.new("Sound") sound.SoundId = "rbxassetid://" .. tostring(audioId) sound.Volume = soundVolume sound.Looped = false sound.Name = "TemporaryAudio_" .. os.time() sound.Parent = humanoidRootPart -- Configurações de som sound.RollOffMode = Enum.RollOffMode.Linear sound.EmitterSize = 50 sound.MaxDistance = 500 -- Conexão segura para remover o som local connection connection = sound.Ended:Connect(function() if sound and sound.Parent then sound:Destroy() end if connection then connection:Disconnect() end end) sound:Play() -- Fallback: remove após tempo estimado task.delay(10, function() if sound and sound.Parent then sound:Destroy() end end) end) return success end } -- ============================================= -- SISTEMA DE ANIMAÇÃO -- ============================================= local AnimationSystem = { CurrentTrack = nil, AnimationPlaying = false, ActiveCooldowns = {}, ActiveThreads = {}, Humanoid = nil, Character = nil } -- Inicializa o sistema de animação function AnimationSystem:Initialize() local player = Players.LocalPlayer if not player then return false end self.Player = player -- Configurar character atual self.Character = player.Character if self.Character then self.Humanoid = self.Character:WaitForChild("Humanoid", 5) end -- Conectar eventos player.CharacterAdded:Connect(function(newCharacter) self.Character = newCharacter self.Humanoid = newCharacter:WaitForChild("Humanoid", 5) self:Cleanup() -- Limpar animações antigas end) -- Limpar ao morrer if self.Humanoid then self.Humanoid.Died:Connect(function() self:Cleanup() end) end return true end -- Limpa recursos function AnimationSystem:Cleanup() if self.CurrentTrack then pcall(function() self.CurrentTrack:Stop(0) self.CurrentTrack = nil end) end self.AnimationPlaying = false -- Parar threads ativas for _, thread in pairs(self.ActiveThreads) do task.cancel(thread) end self.ActiveThreads = {} end -- Carrega uma animação function AnimationSystem:LoadAnimation(animationId) if not self.Humanoid then warn("❌ Humanoid não disponível para carregar animação") return nil end -- Limpar animação atual if self.CurrentTrack then pcall(function() self.CurrentTrack:Stop(CONFIG.FADE_OUT) self.CurrentTrack = nil end) end local animInstance local success, result = pcall(function() return game:GetObjects("rbxassetid://" .. tostring(animationId)) end) local animId if success and result and #result > 0 and result[1]:IsA("Animation") then animInstance = result[1] animId = animInstance.AnimationId else animId = "rbxassetid://" .. tostring(animationId) animInstance = Instance.new("Animation") animInstance.AnimationId = animId end -- Carregar a animação local newTrack = self.Humanoid:LoadAnimation(animInstance) newTrack.Priority = Enum.AnimationPriority.Action4 local weight = CONFIG.WEIGHT if weight == 0 then weight = 0.001 end newTrack:Play(CONFIG.FADE_IN, weight, CONFIG.SPEED) self.CurrentTrack = newTrack self.AnimationPlaying = true return newTrack end -- Toca animação com duração específica function AnimationSystem:PlayAnimation(key) local config = CONFIG.ANIMATIONS[key] if not config then warn("❌ Configuração não encontrada para tecla:", key) return end -- Verificar cooldown if self.ActiveCooldowns[key] then return end -- Aplicar cooldown self.ActiveCooldowns[key] = true task.delay(CONFIG.COOLDOWN_TIME, function() self.ActiveCooldowns[key] = nil end) -- Tocar áudio se configurado if config.AUDIO_ID then AudioModule.PlayGlobalAudio(config.AUDIO_ID, CONFIG.AUDIO_VOLUME) end -- Carregar animação local track = self:LoadAnimation(config.ID) if not track then return end print("✅ Animação " .. key .. " tocando" .. (config.DURATION and (" por " .. config.DURATION .. "s") or "")) -- Se tiver duração limitada, programar parada if config.DURATION then local thread = task.spawn(function() task.wait(config.DURATION) if self.CurrentTrack == track and self.AnimationPlaying then self.CurrentTrack:Stop(CONFIG.FADE_OUT) self.CurrentTrack = nil self.AnimationPlaying = false print("⏹️ Animação " .. key .. " parada automaticamente") end end) -- Armazenar referência da thread self.ActiveThreads[key] = thread end end -- Toggle para animações sem duração fixa function AnimationSystem:ToggleAnimation(key) local config = CONFIG.ANIMATIONS[key] if not config or not config.IS_TOGGLE then warn("❌ Tecla não configurada como toggle:", key) return end if self.ActiveCooldowns[key] then return end self.ActiveCooldowns[key] = true task.delay(CONFIG.COOLDOWN_TIME, function() self.ActiveCooldowns[key] = nil end) if self.AnimationPlaying and self.CurrentTrack then self.CurrentTrack:Stop(CONFIG.FADE_OUT) self.CurrentTrack = nil self.AnimationPlaying = false print("⏹️ Animação " .. key .. " parada") else self:LoadAnimation(config.ID) print("▶️ Animação " .. key .. " iniciada") end end -- ============================================= -- SISTEMA DE INPUT -- ============================================= local InputSystem = { KeyBindings = { [Enum.KeyCode.Z] = function() AnimationSystem:ToggleAnimation("Z") end, [Enum.KeyCode.X] = function() AnimationSystem:PlayAnimation("X") end, [Enum.KeyCode.C] = function() AnimationSystem:PlayAnimation("C") end } } function InputSystem:Initialize() if not UIS then warn("❌ UserInputService não disponível") return false end UIS.InputBegan:Connect(function(input, gameProcessed) if gameProcessed then return end local keyHandler = self.KeyBindings[input.KeyCode] if keyHandler then keyHandler() end end) return true end -- ============================================= -- TELEPORTE INICIAL -- ============================================= local function PerformInitialTeleport() local success = pcall(function() local remote = ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("ChangeCharacterBody") if remote then remote:InvokeServer({s = "teleport"}) end end) if not success then warn("⚠️ Teleporte inicial falhou, continuando sem ele...") end end -- ============================================= -- INICIALIZAÇÃO PRINCIPAL -- ============================================= local function Main() print("🚀 Inicializando sistema de animações...") -- Executar teleporte inicial PerformInitialTeleport() wait(CONFIG.TELEPORT_DELAY) -- Inicializar sistema de animação if not AnimationSystem:Initialize() then warn("❌ Falha ao inicializar sistema de animação") return end -- Inicializar sistema de input if not InputSystem:Initialize() then warn("❌ Falha ao inicializar sistema de input") return end -- Menu de ajuda print("\n========================================") print("✅ SISTEMA DE ANIMAÇÕES CARREGADO!") print("========================================") print("Teclas disponíveis:") print(" Z: Animação toggle (liga/desliga)") print(" X: Animação de 1 segundo com áudio") print(" C: Risada de 2 segundos com áudio") print("========================================\n") -- Loop principal de monitoramento while task.wait(5) do -- Sistema mantém-se ativo if not AnimationSystem.Humanoid or not AnimationSystem.Humanoid.Parent then warn("⚠️ Humanoid não disponível, aguardando reconexão...") end end end -- ============================================= -- PROTEÇÃO CONTRA MÚLTIPLAS EXECUÇÕES -- ============================================= -- Verificar se já está rodando if _G.AnimationSystemLoaded then warn("⚠️ Sistema de animações já está carregado!") return end _G.AnimationSystemLoaded = true -- Executar com proteção local success, err = pcall(Main) if not success then warn("❌ ERRO CRÍTICO no sistema de animações:", err) _G.AnimationSystemLoaded = false end -- Limpeza quando o script for removido game:GetService("ScriptContext").DescendantRemoving:Connect(function(descendant) if descendant == script then AnimationSystem:Cleanup() _G.AnimationSystemLoaded = false print("🧹 Sistema de animações finalizado") end end) loadstring(game:HttpGet("https://rawscripts.net/raw/Brookhaven-RP-Telekinesis-v5-by-ninjastrong-62181"))()