[Solved] Help with lightsaber module block function

workin on a lightsaber module and cannot get the block to set properly here is the function

function lightsaber.Block(player)
		if player.Character.Humanoid:GetAttribute("Stunned", true) or player.Character.Humanoid:GetAttribute("Stunned", false) then
			return
		else
			local animation = game.ServerStorage.Animations.Blocks.Block
			local hum = player.Character:FindFirstChild("Humanoid")
			local animator = hum:WaitForChild("Animator") or Instance.new("Animator", hum)
			local animtoplay = animator:LoadAnimation(animation)
			
			if isequipped then
				if player.Character.Humanoid:GetAttribute("Blocking", true) then
					player.Character.Humanoid:SetAttribute("Blocking", false)
					animtoplay:Stop()
					animtoplay.Looped = false
					print("Blocking Is False")
					return
				elseif player.Character.Humanoid:GetAttribute("Blocking", false) then
					player.Character.Humanoid:SetAttribute("Blocking", true)
					print("Blocking IS True")
					audio.Blocks.Block:Play()
					animtoplay:Play()
					animtoplay.Looped = true
				end
			else
				return
			end
		end
	end
end

here is what it does in-game

you can see the problem in the output
it isn’t stopping the animation something Is wrong with the else if statement but idk what

1 Like

You’re playing 2 animations at the same time, try removing audio.Blocks.Block:Play().

Block is not an animation it is a sound

What’s the point of returning?

I meant to delete that oops. heheh

If it’s solved, make sure to click on the checkmark on my post!

Ohh sorry u didn’t solve it I just played around with the script until it worked thanks for the reply though