local char = workspace:WaitForChild(player.Name)
player.CharacterAdded:Connect(function(character)
char = character
end)
This worked:
function getMouseAndTargetLocation(cursorPosition)
local origin = char.Head.Position
local direction = (Mouse.Hit.p - origin).Unit * 6
local ray = Ray.new(origin, direction)
return workspace:FindPartOnRayWithIgnoreList(ray, char:GetDescendants())
end
This didn’t:
function getMouseAndTargetLocation(cursorPosition)
local origin = char.Head.Position
local direction = (Mouse.Hit.p - origin).Unit * 6
local ray = Ray.new(origin, direction)
return workspace:FindPartOnRayWithIgnoreList(ray, char)
end
The one with GetDescendants works because the function returns a table, while passing just the character passes a lone instance. You thus need to pass a table yourself that includes the character.