[SOLVED] Thank you!

I am making a gun system and the filter list won’t work. It won’t filter out my Roblox character. Here is a video:


Here is a sample of my code, don’t worry about undefined variables/arguments as this is only a sample of a much larger script:

local rayP = RaycastParams.new()
rayP.FilterDescendantsInstances = {player.Character}
rayP.FilterType = Enum.RaycastFilterType.Blacklist

		local raycastResult = workspace:Raycast(handle.Position, (hit - handle.Position)*range)

		if raycastResult then
			local hitPart = raycastResult.Instance
			local model = hitPart:FindFirstAncestorOfClass("Model")
			print("Model - "..model.Name)
			if model then
				local hum = model:FindFirstChild("Humanoid")
				if hum then
					if hitPart.Name == "Head" and headDamageEnabled then
						hum.Health -= headDamage
					else
						hum.Health -= damage
					end
				end
			end
		end

Pay attention to the output in the video, it prints my character name (Model - falcon2666) as it should filter it out because of the filter list. It damages me if I shoot away.

Any help is appreciated :slight_smile:!

rayP.FilterDescendantsInstances = {player.Character}

You’re not getting all of the characters parts, such as the players torso, limbs etc.
It should be:
rayP.FilterDescendantsInstances = {player.Character:GetChildren()}

Good suggestion, however the blacklist filter type, should filter the children of my character. A work-around should be fine.

Ah, I think you forgot to include the RaycastParams in the workspace:Raycast function.
Switch that line up with

local raycastResult = workspace:Raycast(handle.Position, (hit - handle.Position)*range,rayp)

Also, you don’t need to use :GetChildren() in a FilterDescendantsInstances table.

Oooo…I think you are right, I’ll try it later.