Why does this happen with the animations?

so im making an emote tool, and this is what i have so far

i kind of tried to chatgpt my way through this cause just couldnt figure out why it did that at all

heres the script it made me, must be a mess


– SERVICES

local Players = game:GetService(“Players”)
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)


– TOOL & ANIMATIONS

local tool = script.Parent

– Main animation (required)
local mainAnim = tool:WaitForChild(“Animation”)

– Freeze animation (optional)
local freezeAnim = tool:FindFirstChild(“FreezeIdle”)


– TRACK VARIABLES

local mainTrack – Holds currently playing main animation
local freezeTrack – Holds currently playing freeze animation
local mainEndedConnection – Holds Ended event for main animation


– STATE

local equipped = false – Track whether the tool is equipped
local FADE_TIME = 0.2 – Smooth fade in/out for animations


– PLAY ANIMATION FUNCTION

– Plays an animation smoothly
@param animInstance Animation object
@param looped Boolean for looping
@param speed Animation speed multiplier
@param priority Animation priority enum
@param fadeTime Optional fade duration
local function playAnimation(animInstance, looped, speed, priority, fadeTime)
local animator = humanoid:FindFirstChildOfClass(“Animator”)
if not animator then return end
if animInstance.AnimationId == “” then
warn(“Animation”, animInstance.Name, “has no AnimationId!”)
return
end

local track = animator:LoadAnimation(animInstance)
track.Priority = priority or track.Priority
track.Looped = looped or false
if speed then track:AdjustSpeed(speed) end
track:Play(fadeTime or FADE_TIME)
return track
end


– PLAY FREEZE ANIMATION (OPTIONAL)

– Stops existing freeze animation and plays it looping
local function playFreezeAnimation()
if not freezeAnim then return end
if freezeTrack then
freezeTrack:Stop(FADE_TIME)
freezeTrack = nil
end
freezeTrack = playAnimation(freezeAnim, true, 1, Enum.AnimationPriority.Action2, FADE_TIME)
end


– PLAY MAIN ANIMATION

– Stops existing main animation and plays it
– Sets up freeze animation to play when main ends
local function playMainAnimation()
– Stop main track if it exists
if mainTrack then
mainTrack:Stop(FADE_TIME)
mainTrack = nil
end

– Disconnect any previous Ended event to prevent stacking
if mainEndedConnection then
mainEndedConnection:Disconnect()
mainEndedConnection = nil
end

– Play main animation
mainTrack = playAnimation(mainAnim, false, 1, Enum.AnimationPriority.Action, FADE_TIME)

– Connect freeze animation on main animation end
if freezeAnim then
mainEndedConnection = mainTrack.Ended:Connect(function()
if not equipped then return end
playFreezeAnimation()
end)
end
end


– TOOL EQUIPPED

tool.Equipped:Connect(function()
equipped = true
playMainAnimation() – Trigger main animation on equip
end)


– TOOL UNEQUIPPED

tool.Unequipped:Connect(function()
equipped = false

– Stop main animation if playing
if mainTrack then
mainTrack:Stop(FADE_TIME)
mainTrack = nil
end

– Stop freeze animation if playing
if freezeTrack then
freezeTrack:Stop(FADE_TIME)
freezeTrack = nil
end

– Disconnect main Ended connection
if mainEndedConnection then
mainEndedConnection:Disconnect()
mainEndedConnection = nil
end
end)

1 Like

trying to get rid of that arm flap glitch thingy

1 Like

Could i see the Original Animation

1 Like

recording is in process, my friends the one who made the animation so they’re recording it rn

1 Like


first one

1 Like

AnimationTrack is an instance;
You must properly destroy them.

Also you should be pooling them anyway cause recompiling AnimationTrack is very expensive.

1 Like

im not very familiar with this

1 Like

i think i solved my own script a bit but i will def look into your thingy, thank you

1 Like

nevermind not fixed im sorry, its still doing the weird arm flapping thing

1 Like

are you still perhaps available to help me? @faresalqrni143

1 Like

anyoooooneee? im still stuck on this

1 Like

why would you need a freeze animation. if you really want to stop it just do

local mainAnim = tool:WaitForChild("Animation")
mainAnim:Play()
mainAnim:Stop()

THIS IS AN EXAMPLE. dont do the same to your script

1 Like

alright thank you i will note this down

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.