#Coding animations to not have start tweening

1 messages · Page 1 of 1 (latest)

spice ivy
spice ivy
#

its basically just if checks to play and stop animations the whole way

winged valley
#

Not gonna lie, your code is poorly written.

#

Alot of nests.

acoustic frigate
winged valley
#

And another thing, when you are checking the air value if it is false, you can do: if not

spice ivy
#

ik

#

i have more elses down the screen

winged valley
#

Because doing == false is redundant and it's always recommened to use not instead of ==.

spice ivy
#

ye ik

winged valley
spice ivy
#

the only problem is the tweening of the animations and idk why it happends

winged valley
#

t you using it?

winged valley
spice ivy
#

wdym by send it in chat

winged valley
#

The code.

spice ivy
#

local animator = script.Parent:WaitForChild("Humanoid"):WaitForChild("Animator")

local fall = animator:LoadAnimation(script:WaitForChild("Fall"))
local walk = animator:LoadAnimation(script:WaitForChild("Walk"))
local idle = animator:LoadAnimation(script:WaitForChild("Idle"))

game["Run Service"].RenderStepped:Connect(function()

if script.Parent:FindFirstChild("HumanoidRootPart") then
    local still = false
    if script.Parent:FindFirstChild("HumanoidRootPart"):FindFirstChildWhichIsA("BodyVelocity").Velocity.Magnitude < 1 then
        still = true
    end
    if script.Parent.movement.AIR.Value then
        if walk.IsPlaying then
            walk:Stop()
        end
        if idle.IsPlaying then
            idle:Stop()
        end
        if fall.IsPlaying then
        else
            fall:Play()
        end

    end

    if script.Parent.movement.AIR.Value == false then
        
        if fall.IsPlaying then
            fall:Stop()
        else

        end
        
        if still then
            if walk.IsPlaying then
                walk:Stop()
            end
            if idle.IsPlaying then
            else    
                idle:Play()
            end
        else
            if idle.IsPlaying then
                idle:Stop()
            end
            if walk.IsPlaying then
            else    
                walk:Play()
            end
        end
    

    

    end
end

end)

winged valley
#
        if script.Parent.movement.AIR.Value then
            if walk.IsPlaying then
                walk:Stop()
            end
            if idle.IsPlaying then
                idle:Stop()
            end
            if fall.IsPlaying then
            else
                fall:Play()
            end

        end

        if script.Parent.movement.AIR.Value == false then

            if fall.IsPlaying then
                fall:Stop()
            else

            end

            if still then
                if walk.IsPlaying then
                    walk:Stop()
                end
                if idle.IsPlaying then
                else
                    idle:Play()
                end
            else
                if idle.IsPlaying then
                    idle:Stop()
                end
                if walk.IsPlaying then
                else
                    walk:Play()
                end
            end
#

I believe this is the core issue.

#

When you are checking the air value if it's false, you need to add a not

subtle craterBOT
#

studio** You are now Level 12! **studio

winged valley
#

That should be the fix.

#

Let me give me some advice, nesting can make your code unreadable for other developers to read.

#

And always make variables please.

spice ivy
#

the problem isnt the code, its the animations not being instant

winged valley
#

Wait, have you ever tried using HumanoidStateChanged before?

spice ivy
#

yse

winged valley
#

Why don't not use that?

spice ivy
#

imma try it

winged valley
#

Here

#

Don't do IsPlaying() It never works.

spice ivy
#

alr

#

didnt fix the issue