I'm making a script and the script cooks the food you put on the stove, but I don't want it to keep cooking after you take it off the oven. How could I make the code stop?
script.Parent.Touched:Connect(function(hit)
if hit.Cookable ~= nil then
-- cooking code here, but I don't want to addon
end
end)
script.Parent.TouchEnded:Connect(function(hit)
if hit.Cookable ~= nil then
-- where to stop the script (so that way the food doesnt keep cooking after you take it off the
-- stove)
end
end)
If you need more code or information or anything, let me know.

2 comments
you can add a while loop that depends on the var canCook in your cooking code and just say the canCook is false when TouchEnded
If you want the program to only run once during the Server's lifespan, you can disconnect both RBXScriptSignals.