Raycast still hitting character although in exclude list

Humour me if I did something stupid, this is my first time trying raycasts

I want the ray to hit anything but the player, though no matter what I try, it still hits the local player, any help is appreciated

	local length = 1000
	
	local raycastParams = RaycastParams.new()
	raycastParams.FilterType = Enum.RaycastFilterType.Exclude
	raycastParams.FilterDescendantsInstances = {character}
	
	local raycastResult = workspace:Raycast(camera.CFrame.Position, camera.CFrame.LookVector * length)
	print("Instance:", raycastResult.Instance)
1 Like

You’re not applying the raycast params on the raycast. Use this code sample as a guide.

3 Likes

oh my god how on earth did I not notice that I hadn’t added the parameters

thank you

2 Likes

I was just about to say the same thing, you beat me to it though :joy:

3 Likes

No prob, in the future make sure to look over the Roblox API Reference as looking for issues there usually is faster than here, and it also helps you learn.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.