--	print("CurrentAnim ", currentAnim, " ", frameName)

	if (frameName == "End") then
		if currentAnim == "walk" then
			runAnimTrack.TimePosition = 0.0
			currentAnimTrack.TimePosition = 0.0
		else
	--		print("Keyframe : ".. frameName)
	
			local repeatAnim = currentAnim
			-- return to idle if finishing an emote
			if (emoteNames[repeatAnim] ~= nil and emoteNames[repeatAnim] == false) then
				repeatAnim = "idle"
			end
			
			local animSpeed = currentAnimSpeed
			playAnimation(repeatAnim, 0.15, Humanoid)
			setAnimationSpeed(animSpeed)
		end
	end
end

function rollAnimation(animName)
	local roll = math.random(1, animTable[animName].totalWeight) 
	local origRoll = roll
	local idx = 1
	while (roll > animTable[animName][idx].weight) do
		roll = roll - animTable[animName][idx].weight
		idx = idx + 1
	end
	return idx
end

function playToyAnimation(AnimName) 
	local ToyObject = Figure:FindFirstChild("Toy");
	
	if ( ToyObject and ToyObject:FindFirstChild("AnimationController") ) then
		
		local AnimController = ToyObject.AnimationController;
		local AnimObject = ToyObject.AnimationObjects:FindFirstChild(AnimName);
		if ( AnimObject ) then
			
			if ( CurrentToyAnimation ~= nil ) then
				CurrentToyAnimation:Stop();
				CurrentToyAnimation:Destroy();
				CurrentToyAnimation = nil;
			end
			
			local AnimTrack = AnimController.Animator:LoadAnimation( AnimObject );
			AnimTrack:Play();
			CurrentToyAnimation = AnimTrack;
		end
		
	end
	
end

function playAnimation(animName, transitionTime, humanoid) 
		
	local idx = rollAnimation(animName)
	