Blockcast detection inconsistenty

i’ve scripted a combat system. and i’ve made a bot which does combat so i can test the damage and things.

but the bot only detects you once and if you’re still stay still it will ignore you till you move

but the when it’s done by the player. it detects every hit, so i’m confused i thought blockcast was supposed to do one or the other not both.

now i don’t feel comfortable using this as my main detection for combat. usually i would just change the detection method, but i’ve seen posts on the forum highly praise the performance and responsiveness of raycast. and i wanted that for my combat.

is anyone able to explain this behaviour?

This is the detection code

Detection = function(player)
			local root = player.Character.HumanoidRootPart
			local params =
			params.FilterDescendantsInstances = {player.Character,nil}
			params.FilterType = Enum.RaycastFilterType.Exclude
			local start = os.time()			
			print("Looking for target")
			local targetfound = false
			while not targetfound do
				local direction = root.CFrame.LookVector * 20
				local result1 = workspace:Blockcast(root.CFrame *,0,-root.Size.Z/2),root.Size * 2,root.CFrame.LookVector * 20,params)
				CastVisual:Blockcast(root.CFrame *,0,-root.Size.Z/2),root.Size * 2,direction, params)
				local enemyhumanoid = result1 and result1.Instance.Parent:FindFirstChild("Humanoid") or false
				if enemyhumanoid then
					targetfound = enemyhumanoid.Parent
				if os.time() - start >= .4 then break end
			return targetfound



1 Like