What does your setup for CastParams look like?
Also, I believe I ran into a similar issue a while back where if the ray (direction vector) provided to a raycast doesn’t hit the outside faces (aka the ray is completely enclosed within the part) then it will not detect it.
Hmm… and you’re absolutely sure that a part exists (that isn’t a child of the Character) between these points? You could try a bit of manual debugging by creating a part at the origin of the raycast and another at the end to visually see where the ray is being cast. Something like:
origin = Instance.new("Part", workspace)
origin.Anchored = true
origin.Size = Vector3.new(0.2,0.2,0.2)
origin.CFrame = CFrame.new(Character.HumanoidRootPart.Position)
dest = Instance.new("Part", workspace)
dest.Anchored = true
dest.Size = Vector3.new(0.2,0.2,0.2)
dest.CFrame = CFrame.new(Character.HumanoidRootPart.Position + (castData.Origin - Character.HumanoidRootPart.Position))
-- or whatever you're providing to the 2nd argument of the raycast call ^
Red parts being the 2 parts. So it seems dest is being set at origin of the bullet
This also shows the raycast that’s being done on the bullet
And while I could use the Direction of the ray, I only want to check between the character and their gun for walls
-- Set up cast behavior
local CastBehavior = FastCast.newBehavior()
CastBehavior.RaycastParams = CastParams
CastBehavior.Acceleration = Vector3.new(0, -GRAVITY, 0)
local Origin = castData.Origin--firePoint
local Direction = castData.Direction--(mousePosition - Origin).Unit
local ActiveCast = Caster:Fire(Origin, Direction, SPEED, CastBehavior) -- Fire shot
EDIT Upon further testing, I think what I’ve got should work. I do this same ray on the client, and if there gun is inside a part, then I fire from their face. I was just trying to add an extra level of protection on the server in case anyone tries to bypass that