local x if hum.RigType==Enum.HumanoidRigType.R6 then x=script.Parent.TakeABiteR6 else x=script.Parent.TakeABiteR15 end local k=hum:LoadAnimation(x)script.Parent.Activated:connect(function()if not eating then eating=true k:Play()k.KeyframeReached:Connect(function(x)if x=="\066\105\116\101"then sound.TimePosition=.3 sound:Play()wait(.5)script.Parent.BiteTaken:FireServer()end end)end end)k.Stopped:Connect(function()script.Parent.AppleFinished:FireServer()end)
-- 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)
