I'm trying to make it so that when a patty touches a grill, it will slowly cook, 5 stages in total. When it touches it though, it continues cooking regardless if I take it off the grill. Also, the prints from the onHit and onGone function are delayed.

Code:

touching = false

function cook(hit)
	if hit.stage.Value == 1 and touching == true then
		script.Parent.sizzle:Play()
		wait(4)		
		hit.BrickColor = BrickColor.new(18)
		hit.stage.Value = 2
		script.Parent.sizzle:Stop()
	end
	if hit.stage.Value == 2 and touching == true then
		script.Parent.sizzle:Play()
		wait(4)
		hit.BrickColor = BrickColor.new(217)
		hit.stage.Value = 3
		script.Parent.sizzle:Stop()
	end
	if hit.stage.Value == 3 and touching == true then
		script.Parent.sizzle:Play()
		wait(5)
		hit.BrickColor = BrickColor.new(26)
		hit.stage.Value = 4
		script.Parent.sizzle:Stop()
	end
	if hit.stage.Value == 4 and touching == true then
		script.Parent.sizzle:Play()
		wait(6)
		hit.BrickColor = BrickColor.new(1003)
		hit.stage.Value = 5
		hit.Fire.Enabled = true
		script.Parent.sizzle:Stop()
	end
end

function onHit(hit)
	if hit.Name == "Patty" then
		cook(hit)
		touching = true
		print(hit.Name.." is now touching")
	end
end

function onGone(hit)
	if hit.Name == "Patty" then
		touching = false
		print(hit.Name.." is no longer touching")
		script.Parent.sizzle:Stop()
		script.Parent.antistop.Disabled = true
		wait(0.01)
		script.Parent.antistop.Disabled = false
	end
end



script.Parent.Touched:connect(onHit)
script.Parent.TouchEnded:connect(onGone)

Like I said, it all works fine but it keeps cooking even if I take it off of the grill.

Edit: antistop is a script that manually loops the "sizzle" sound at a certain time in the audio. It works fine.