Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Keyframe reached not executing?

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

✓ Accepted answer

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

This discussion is preserved as it was. New answers, comments, and votes are closed.