Problem with Raycasting

So i was warking on a FPS system and i have a problem with raycasting the shoot position, as you can see in the video below the bullet gets shooted when the player isn’t aiming but if the player is aiming the raycastResult returns nil.

These are the raycast params:

local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = {WeaponInHand, character, camera}
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist

Sorry about the lag.

So i added the player character to the raycast params to make it ignored by the raycast function as i’m using the blacklist type but the raycast actually finds the character and so returns nil. What i want to know is how can i make it so if it finds the character it continues raycasting instead of just returning nil?

To my knowledge the blacklist should work by continuing to raycast even when it finds the character. What was the code that executes the raycast?

This is the Raycast line:

local raycastResult = game.Workspace:Raycast(Weapon.ShootPart.Position, (mouse.Hit.p - Weapon.ShootPart.CFrame.p) * 500, raycastParams)

I also tried to use mouse.TargetFilter but nothing changed

Ok problem solved. The TargetFilter had to be the camera and not the character.

1 Like