I am making a keybind system that does a specific task to the server. However, I am unsure if I should return each time the keybind has already been met. Here is the code I have below:
RemoteEvents.keybindEvent.OnServerEvent:Connect(function(player: Player, input)
if input == Enum.KeyCode.One then
Ingame_Functions.equipWeapon(player.Character, primaryWeapon)
end
if input == Enum.KeyCode.Two then
Ingame_Functions.equipWeapon(player.Character, secondaryWeapon)
end
if input == Enum.KeyCode.Three then
Ingame_Functions.equipWeapon(player.Character, meleeWeapon)
end
end)
Question: Should I return each time the condition has already been met? Would this improve my performance or am I wasting my time typing return for each keybind?
Theoretical answer:
RemoteEvents.keybindEvent.OnServerEvent:Connect(function(player: Player, input)
if input == Enum.KeyCode.One then
Ingame_Functions.equipWeapon(player.Character, primaryWeapon)
return
end
if input == Enum.KeyCode.Two then
Ingame_Functions.equipWeapon(player.Character, secondaryWeapon)
return
end
if input == Enum.KeyCode.Three then
Ingame_Functions.equipWeapon(player.Character, meleeWeapon)
return
end