-
What do you want to achieve?
Raycast that checks for another humanoid (especially npc) -
What is the issue?
It keeps returning the tool itself or the player’s accessories. -
What solutions have you tried so far?
I have looked almost everywhere for solutions and tried them all, but none of them worked
-- raycasting things
local mouse = player:GetMouse()
local origin = character.Head
local AskingRange = 16
local cantAsk = {
tool.Handle,
character:GetDescendants(),
character:GetChildren()
}
local rcParams = RaycastParams.new()
rcParams.FilterType = Enum.RaycastFilterType.Exclude
rcParams.FilterDescendantsInstances = cantAsk
function TimeToAsk(player, mousePos, originPos)
print("It was " .. player.Name)
local direction = (mousePos - originPos).Unit * AskingRange
local result = workspace:Raycast(originPos, direction)
if result then
print(result.Instance.Name)
end
end
Note: Everything else works fine, it is just this piece of code that I need help with.