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

Keyframe reached not executing?

Asked by 6 years ago
Edited 6 years ago

when the idle animation is done its suppose to print that is done, but it doesnt, am i using it correctly?

local animation = Instance.new("Animation")
local psuedoanimetrack

local playablity = true
local ape = script.Parent
local animetable ={
    idle ="http://www.roblox.com/Asset?ID=1265687850",
    run ="http://www.roblox.com/Asset?ID=1265540413"

    }

function playdaanime (animName,humanoid)
    local anin = animetable[animName]
    animation.AnimationId= anin
    psuedoanimetrack= humanoid:LoadAnimation(animation)
    psuedoanimetrack:Play()
end
wait(10)

while true do
    local speed = Vector3.new(ape.HumanoidRootPart.Velocity.X, 0, ape.HumanoidRootPart.Velocity.Z).magnitude
    if playablity and speed >.5 then
        print("im moving")
        playablity = false
        playdaanime("run",ape.Humanoid)

        psuedoanimetrack.KeyframeReached:connect(function()
            print("im done moving")
            playablity= true
        end)

    elseif playablity then
        print("im idle")
    playablity = false

        playdaanime("idle",ape.Humanoid)
        psuedoanimetrack.KeyframeReached:connect(function()
            print("im done in idle")
            playablity= true
        end)

    end
    wait()
    end




1 answer

Log in to vote
0
Answered by
Radstar1 270 Moderation Voter
6 years ago

When you make a keyframe in the animation editor you have to give it a name. That name is what you pass in the .KeyframeReached parameter.

Let's say you named your keyframe: "Slam".

Then this is the line you would use in order to make sure it runs on that keyframe.

Example:

psuedoanimetrack.KeyframeReached:Connect(function(Slam)
--Do whatever
end
Ad

Answer this question