I am trying to create an animation system. I’m trying to exit an if statement in a LocalScript. I was wondering if I should exit control flow statements with break end or simply end statements. This is a part of my script.
script.Parent.MouseButton1Click:Connect(function()
if Character.Animation then
--End or break end here
else
--Other stuff
end
end)
I heard that a lot of people are against redundant if-statements and do use exit control flows pretty often, but it’s a matter of personal choice and whatever makes your life easier
For example, these two functions do the same thing, but which one do you think is better? It’s completely up to you
function foo(a, b, c)
if a then
if b then
if c then
return true
end
return 'missing c'
end
return 'missing b'
end
return 'missing a'
end
function foo(a, b, c)
if not a then return 'missing a' end
if not b then return 'missing b' end
if not c then return 'missing c' end
return true
end