Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local Players = game:GetService("Players")
- local LocalPlayer = Players.LocalPlayer
- local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
- local Humanoid = Character:WaitForChild("Humanoid")
- -- IDs das animações (ambos no formato rbxassetid://)
- local OLD_ANIMATION_ID = "rbxassetid://87259391926321"
- local NEW_ANIMATION_ID = "rbxassetid://78254309368241"
- -- Função para substituir a animação
- local function ReplaceAnimation(oldId, newId)
- -- Verifica se o Humanoid existe
- if not Humanoid then
- warn("Humanoid não encontrado!")
- return
- end
- -- Obtém o Animator do Humanoid
- local Animator = Humanoid:FindFirstChildOfClass("Animator")
- if not Animator then
- warn("Animator não encontrado!")
- return
- end
- -- Itera sobre todas as animações carregadas no Animator
- for _, track in pairs(Animator:GetPlayingAnimationTracks()) do
- -- Verifica se a animação atual corresponde ao ID antigo
- if track.Animation and track.Animation.AnimationId == oldId then
- -- Cria uma nova animação com o ID novo
- local newAnimation = Instance.new("Animation")
- newAnimation.AnimationId = newId
- -- Substitui a animação antiga pela nova
- local newTrack = Animator:LoadAnimation(newAnimation)
- newTrack:Play()
- -- Para a animação antiga
- track:Stop()
- print("Animação substituída com sucesso!") -- Apenas para debug
- break
- end
- end
- end
- -- Substitui a animação quando o personagem é carregado
- Character:WaitForChild("Humanoid").Died:Connect(function()
- -- Reconecta quando o personagem respawna
- Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
- Humanoid = Character:WaitForChild("Humanoid")
- end)
- -- Substitui a animação em um loop constante
- while true do
- ReplaceAnimation(OLD_ANIMATION_ID, NEW_ANIMATION_ID)
- task.wait(0.1) -- Verifica a cada 0.1 segundos
- end
Advertisement
Add Comment
Please, Sign In to add comment