Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to immediately change the idle animation?

Asked by 4 years ago

I have two custom idle animations; one for combat stance, and one for normal. However, I can't seem to immediately change the idles and I have to do another action like walking for the idle to reset.

https://gyazo.com/cffb8ecc1dfb03ec878b0e883478fe93

This is part of a local script in StarterPlayerScripts that handles the tool equips

local CAS = game:GetService("ContextActionService")
local UIS = game:GetService("UserInputService")
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local c = player.Character local h = c:WaitForChild("Humanoid")
local canPunch = false


CAS.LocalToolUnequipped:Connect(function(tool)
    if tool.Name == "Combat" then
        c.Animate.idle.Animation1.AnimationId = "rbxassetid://4436316984"
        canPunch = false
    end
end)

CAS.LocalToolEquipped:Connect(function(tool)
    if tool.Name == "Combat" then
        c.Animate.idle.Animation1.AnimationId = "rbxassetid://4441952929"
        canPunch = true
    end
end)

I have tried playing a super short animation for a split second upon equip, but that doesn't work.

1
Found 90% of the solution if anyone was wondering. After changing the IDs, you iterate through all of the player's currently playing animations (via Humanoid:GetPlayingAnimationTracks) and Stop() all of them. Then you disable the Animate script and then reenable right after and the IDLES will work. Unfortunately, the walks still don't work Hotfirebird67 16 — 4y

Answer this question