Would having a bunch of else or elseif statements cause lag? aswell as other checks such as if the player is holding a tool, etc

Something on the lines like this

	elseif action == "Shoot" and toolName == "Pistol" then
		Loader.playSound(165946426, Humanoid)
		Loader.loadAnim(toolName, "PistolFire", Animator):Play()
	wait(Loader.loadAnim(toolName, "PistolFire", Animator).Length-0.15)
		Loader.gunMuzzle(Character:WaitForChild(toolName).Flash)
		Loader.gunFlash(Character:WaitForChild("Head"), Color3.fromRGB(255, 255, 0), 3.76)
	elseif action == "Shoot" and toolName == "Axe" then
		
		Loader.playSound(6767836089, Humanoid)
		Loader.loadAnim(toolName, "Attack1", Animator):Play()
		
	elseif action == "Hit" and toolName == "Axe" then
		Loader.playSound(8348697790, Humanoid)
		
	elseif action == "Shoot" and toolName == "Flashlight" then
		Loader.loadAnim(toolName, "Off", Animator):Play()
		wait(Loader.loadAnim(toolName, "Off", Animator).Length- 0.2)
		stop()
		end

Does this affect anything? Does it cause lag or make gameplay terrible?

It doesn’t cause lag, because the script only reads the elseif statement and sees if its true, if it is true, then it executes the script after the statement, otherwise move onto the next elseif statement and goes on until it reaches the else statement.

2 Likes

It’s actually quite performant. However, it is not very efficient to code these and your code gets really messy if you have a whole lot of them.