Well, you need to know that for the major part if and elseif statements won’t be absolutely destroying your game performance. Because of all the script happening at the blink of an eye, one singular if elseif elseif elseif elseif elseif else statement won’t be breaking your game, if it was run 6 times every 4 seconds you would still not see any trouble, even if it was 6 times every 1 second. The issue starts to rise when it’s more than 7 in routine, so they do it every milisecond and they need the response in a milisecond.
What you’re saying about yanderedev having his game being a broken mess because of elseif is kind of a misinformed statement that I shared sometime ago, his game did have a lot of huge elseif statements, but even by turning it into switches the game would still run the same, the issue was on the lack of graphic priority and tool details, which meant that a lot in the game had a lot of polygons, which many were useless, there even was a toothbrush with 500 polygons where you only needed 6!
If you, for some reason, wanted to make a script without using a lot of elseifs you would have to use switches, but because lua doesn’t have switches you can also use dictionaries to make them do something on call, and insert a function to each word of the dictionary
so, basically, instead of doing this
if input == "a" then
do "a"
elseif input == "s" then
do "s"
elseif elseif elseif elseif
you could do this table instead
keymovedon = {
[Enum.KeyCode.W] = function(key, input) if input == Enum.UserInputState.Begin then currenty2 = .5 else currenty2 = 0 end end,
[Enum.KeyCode.A] = function(key, input) if input == Enum.UserInputState.Begin then currentx1 = -.5 else currentx1 = 0 end end,
[Enum.KeyCode.S] = function(key, input) if input == Enum.UserInputState.Begin then currenty1 = -.5 else currenty1 = 0 end end,
[Enum.KeyCode.D] = function(key, input) if input == Enum.UserInputState.Begin then currentx2 = .5 else currentx2 = 0 end end
}
Now, does it improve your performance by a long shot? not really, but it makes the code look much more comfortable at sight, and somewhat more formal.