Invoking problems!

As you can tell from the title, my code has problems with invoking and such. The Invoking function, as portrayed below, seems to not be called correctly which might be the problem. However, I’m unsure what’s wrong with the code itself. Referencing the developer hub, errors still occur even when everything seems to be correct. If you have any idea why this isn’t working, please don’t hesitate to respond. Thanks in advance!

Simplified Version Of My Code:

tool.Equipped:Connect(function()
   tool.Blade.Touched:Connect(function(hit)
         print("sending invoke...")
         local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
         local isBlocking = hitPlayer.Remotes.getBlockingState:Invoke()
         print("recieved: "..isBlocking)
    end)

    Player.Remotes.getBlockingState.OnInvoke = function()
		print("Blocking State Invoke!")
		local isBlocking = false
		for i,v in pairs(Humanoid:GetPlayingAnimationTracks())do
			if v == BlockingTrack then
				isBlocking = true
			end
		end	
		print("returning: "..isBlocking)
		return isBlocking
	end
end)

Output:

sending invoke...
sending invoke...
sending invoke...

From the look of it, your code will only attach an invoke listener to each player when that specific player equips their tool. If the player you hit hasn’t equipped their tool, it won’t connect their invoke handler.

Thanks for the reply! So I added an “or false” to try to prevent the yield for the invoke. To no avail, it seems like it’s still yielding. What can I do to prevent the yielding and make the code run past the invoke?

tool.Blade.Touched:Connect(function(hit)
        print("sending invoke...")
        local hitPlayer = game.Players:GetPlayerFromCharacter(hit.Parent)
        local isBlocking = hitPlayer.Remotes.getBlockingState:Invoke() or false
        print("recieved: "..isBlocking)
    end)