Hey all, I've got a script that checks a recipe, it checks from a table, sees if the ingredients are compatible with a recipe, and then gives the Success or Error message. If the recipe errors, the Error message pops up correctly. If the recipe is successful, the Error message will pop up before the Success message does. I've tracked it down to one line using Prints, and I can't quite figure out the correct phrasing. I've included the remote event script below, and marked the line that the snag happens, on Line 14.
CookingEvent.OnServerEvent:Connect(function(Plr, ResultBtn, ResultFinalResult, ResultMsg, ...) -- last (...) is for multiple ingredients
if Plr.leaderstats.Coins.Value >= 10 then
local CurrentIngredients = {...}
for recipeName, thisRecipe in pairs(recipes) do
local matches = 0
for _, v in pairs(thisRecipe) do
for _, b in pairs(CurrentIngredients) do
if table.find(v,b) and #v == #CurrentIngredients then
matches += 1
wait()
if matches == #v then
onCorrectRecipe(recipeName, CurrentIngredients,Plr,ResultBtn,ResultMsg,ResultFinalResult)
elseif matches ~= #v then -- THIS LINE
onFailedRecipe(recipeName, CurrentIngredients,Plr,ResultBtn,ResultMsg,ResultFinalResult)
end
end
end
end
end
I know I'm doing something simple wrong. Any suggestions to fix that line is much appreciated. Thanks!
