-- setting up the correct animation --

local eatingAnimation
if hum.RigType == Enum.HumanoidRigType.R6 then
	eatingAnimation = script.Parent.TakeABiteR6
else
	eatingAnimation = script.Parent.TakeABiteR15
end
local eatingAnim = hum:LoadAnimation(eatingAnimation)

script.Parent.Activated:connect(function()
	if not eating then
		eating = true
		eatingAnim:Play()
		eatingAnim.KeyframeReached:Connect(function(keyFrame)
			if keyFrame == "Bite" then
				sound.TimePosition = 0.3
				sound:Play()
				wait(0.5)
				script.Parent.BiteTaken:FireServer()
			end
		end)
	end
end)

eatingAnim.Stopped:Connect(function()
	script.Parent.AppleFinished:FireServer()
end)
