So I have a gun with a script inside of it, everything works fine but I’m just adding a few checks for a few new features to it, and so I was creating this raycast however when the raycast is fired it’s saying that it’s not hitting anything.
local rayOrigin = barrel.Position -- barrel of the gun inside of the player
local rayDirection = mouseHit.Position -- mouseHit which is given from a remote event fired from a local script
local blacklist = RaycastParams.new()
blacklist.FilterType = Enum.RaycastFilterType.Blacklist
blacklist.FilterDescendantsInstances =
{
gun, -- trying to blacklist everything inside of the gun and everything inside of the character
char
}
local surfaceRay = workspace:Raycast(rayOrigin, rayDirection * 100, blacklist) -- this is the part that i feel like im probably doing wrong, im trying to create a ray that points in the direction of the mouse cursor in the 3d workspace, therefore ray origin being the barrel, and raydirection being the mouse.Hit.Position and then * 100 in order to make it go past the position of the mouse.Hit.Position
if surfaceRay then
local surfaceHit = surfaceRay.Instance
print(surfaceHit)
local surface = surfaceRay.Normal
print(surface)
else
print("didnt hit anything")
end
I know it’s not hitting anything since it’s printing “didn’t hit anything”
Any help is appreciated