Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I make a raycast function that ignores non-cancollided parts?

I want to make a raycast function that allows you to shoot a ray through bricks that have cancollide turned off. I've tried adding the bricks to the Ignorelist and the mouse TargetFilter, and in both cases, the ray is not accurate, does not fire at the spot that the mouse is pointing to, and ends up being at an offset angle. Help?

3 comments

0

Adding the bricks to the ignorelist would work, it's not accurate because the mouse is focused on the non-collided part.

0

How would I make the mouse ignore the non-collided part? I already tried putting it on the TargetFilter.

0

heres what i would try, i would raycast from the camera to the mouse that continues on, having the parts with cancollide off in that ray's ignorelist too

1 answer

Here's an example of how you can do this:

local ray = Ray.new(player.Lightning.WorldPosition.WorldPosition,player.HumanoidRootPart.CFrame.lookVector.unit*100)
local ignore = workspace.Noncollide:GetChildren();
table.insert(ignore,player)
local Part,Position = game.Workspace:FindPartOnRayWithIgnoreList(ray,ignore)

I hope this helped you.

This discussion is preserved as it was. New answers, comments, and votes are closed.